从存储帐户部署代码时,Azure 函数事件中心触发绑定注册失败

问题描述 投票:0回答:3

使用应用设置

WEBSITE_RUN_FROM_PACKAGE
从存储帐户中的压缩代码部署代码时,事件中心触发器绑定注册失败。出现以下错误:

The binding type(s) eventHubTrigger are not registered

通过 VS code 解压部署时,相同的代码可以正常工作。

主机.json

{
  "version": "2.0",
  "extensionBundle": {
    "id": "Microsoft.Azure.Functions.ExtensionBundle",
    "version": "[2.*, 3.0.0)"
}

函数.json

{
  "bindings": [
    {
      "type": "eventHubTrigger",
      "name": "myEventHubMessage",
      "direction": "in",
      "eventHubName": "eventHubName",
      "connection": "myEventHubReadConnectionAppSetting"
    }
  ]
}
azure azure-functions azure-functions-runtime azure-storage-account azure-functions-core-tools
3个回答
0
投票

更新host.json并添加“扩展”

{
"version": "2.0",

"extensions": {
    "blobs": {},
    "cosmosDb": {},
    "durableTask": {},
    "eventHubs": {},
    "http": {},
    "queues": {},
    "sendGrid": {},
    "serviceBus": {}
},

"extensionBundle": {
    "id": "Microsoft.Azure.Functions.ExtensionBundle",
    "version": "[2.*, 3.0.0)"
}}

0
投票
  • 使用上面在 host.json 中明确提及扩展的技巧
  • 将 host.json 移至代码文件夹上方的一级,我将其保持在同一级别。

PS:这适用于使用 Azure 函数扩展的 VS Code 部署 - 当在根级别上未检测到 host.json 时,VS Code 会根据 Functions.json 中指定的触发器自动安装扩展


0
投票

确保 host.json 不在“.funcignore”中,这将为您带来

The binding type(s) eventHubTrigger are not registered

© www.soinside.com 2019 - 2024. All rights reserved.