未注册 Azure 持久函数实体绑定 - node.js

Azure Durable Function Entity Bindings Not Registered - node.js

尝试在本地测试使用持久实体的 node.js Azure 函数应用程序时,我看到以下消息表明这些绑定未注册:

The binding type(s) 'entityTrigger' are not registered. Please ensure the type is correct and the binding extension is installed.
The binding type(s) 'durableClient' are not registered. Please ensure the type is correct and the binding extension is installed.

我的 host.json 看起来像这样:

{
  "version": "2.0",
  "extensions": {
      "durableTask": {},
      "http": {},
      "queues": {},
      "serviceBus": {}
  },
  "extensionBundle": {
      "id": "Microsoft.Azure.Functions.ExtensionBundle",
      "version": "[1.*, 2.0.0)"
  }
}

函数之一的示例绑定:

{
  "bindings": [
    {
      "name": "context",
      "type": "entityTrigger",
      "direction": "in"
    }
  ],
  "disabled": false
}

已注册其他持久函数绑定,如 orchestrationTrigger,但未注册这些。我安装了 durable-functions npm package 1.4.1 以及 Azure Functions Core Tools 3.0.2534。在缺乏 JS 参考的情况下努力使它工作 material 并且将永远感谢您的帮助。

所以这是因为您 host.json 的 extensionBundle 配置。目前,扩展包仅支持 1.x 版本的 Durable Functions 扩展,不支持实体。但是,在不久的将来,将有第二个版本的扩展包附带 Durable Functions 2.x,它引入了 Durable Entity 支持。届时,您只需将 "version" 字段更改为 "[2.*, 3.0.0)".

请注意,您现在可以通过使用 Azure Functions CLI 手动管理 Durable Functions 扩展来使用 Durable Entities。只需删除 host.json 的扩展包部分,然后 运行 对要安装的每个 Azure Functions 扩展执行以下命令:

func extensions install -p <nuget-package-name> -v <version>

您可以通过查看 nuget.org 找到官方扩展及其最新版本。