作为标题,当我尝试运行基于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的安装,都无法正常工作。
最可怕的是,这曾经在同一台机器上正常工作,突然间它无法正常工作。
答案 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.0
和6.9.0
。
要通过azure-functions-core-tools
安装npm
并进行检查,如下图所示。
下一步是通过MyFunctionProj
初始化项目func
然后使用blob触发器来新建一个函数
.NET Core SDK的要求存在问题。因此,我转到https://www.microsoft.com/net/download进行安装,这里与MacOS不兼容,但是我认为您可以轻松地自行修复。因此,我按照官方安装说明进行安装。
安装.NET Core SDK后,请尝试再次func new
。
就这样完成了。
要更改两个配置文件MyFunctionProj/local.settings.json
和MyFunctionProj/MyBlobTrigger/function.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`"
}
}
{
"bindings": [
{
"name": "myBlob",
"type": "blobTrigger",
"direction": "in",
"path": "<the container name you want to monitor>/{name}",
"connection": "AzureWebJobsStorage"
}
]
}
然后,命令func host start --build
正确启动它。
让我们通过Azure存储资源管理器将名为test.txt
的测试文件上传到在<the container name you want to monitor>
文件中配置的容器function.json
上。而且您会看到MyBlobTrigger
已被触发并且可以正常工作。
希望有帮助。