未注册Azure Function blobTrigger

时间:2019-07-02 01:56:10

标签: azure azure-functions

作为标题,当我尝试运行基于nodejs的azure函数时,遇到以下错误:

The following 1 functions are in error: [7/2/19 1:41:17 AM] ***: The binding type(s) 'blobTrigger' are not registered. Please ensure the type is correct and the binding extension is installed.

我尝试func extensions install --force还是没有运气,知道吗?我的开发环境是macOS,我尝试了基于nodejs的azure-functions-core-tools和基于brew的安装,都无法正常工作。

最可怕的是,这曾经在同一台机器上正常工作,突然间它无法正常工作。

1 个答案:

答案 0 :(得分:0)

基本上,您可以参考Linux Create your first function hosted on Linux using Core Tools and the Azure CLI (preview)的官方教程来开始您的工作。

由于在MacOS和Linux中使用了相同的shell bash,我将在Linux上为您启动示例演示,并避免使用那些不兼容的操作。首先,假设您的环境中有可用的NodeJS运行时。节点和npm的版本分别为v10.16.06.9.0

  1. 要通过azure-functions-core-tools安装npm并进行检查,如下图所示。

    enter image description here

  2. 下一步是通过MyFunctionProj初始化项目func

    enter image description here

  3. 然后使用blob触发器来新建一个函数

    enter image description here

    .NET Core SDK的要求存在问题。因此,我转到https://www.microsoft.com/net/download进行安装,这里与MacOS不兼容,但是我认为您可以轻松地自行修复。因此,我按照官方安装说明进行安装。

    enter image description here

  4. 安装.NET Core SDK后,请尝试再次func new

    enter image description here

    就这样完成了。

    enter image description here

  5. 要更改两个配置文件MyFunctionProj/local.settings.jsonMyFunctionProj/MyBlobTrigger/function.json,如下所示。

    MyFunctionProj / local.settings.json

    {
      "IsEncrypted": false,
      "Values": {
        "FUNCTIONS_WORKER_RUNTIME": "node",
        "AzureWebJobsStorage": "<your real storage connection string like `DefaultEndpointsProtocol=https;AccountName=<your account name>;AccountKey=<your account key>;EndpointSuffix=core.windows.net`"
      }
    }
    

    MyFunctionProj / MyBlobTrigger / function.json

    {
      "bindings": [
        {
          "name": "myBlob",
          "type": "blobTrigger",
          "direction": "in",
          "path": "<the container name you want to monitor>/{name}",                                                                                                  
          "connection": "AzureWebJobsStorage"
        }
      ]
    }
    
  6. 然后,命令func host start --build正确启动它。

    enter image description here

    让我们通过Azure存储资源管理器将名为test.txt的测试文件上传到在<the container name you want to monitor>文件中配置的容器function.json上。而且您会看到MyBlobTrigger已被触发并且可以正常工作。

    enter image description here

希望有帮助。