azure - 无法在 Azure Functions V2 中注册 CosmosDB 绑定(bind)扩展

标签 azure azure-functions azure-cosmosdb

我正在尝试使用 CosmosDB 输入绑定(bind)添加一个新函数(Http 触发器)。

阅读有关 Azure Functions 版本 2 中输入绑定(bind)的手册,我发现我需要注册我的 binging 扩展 ( https://learn.microsoft.com/en-us/azure/azure-functions/functions-triggers-bindings#register-binding-extensions ),并且 azure 门户应该向我显示一些注册提示 ( https://learn.microsoft.com/en-us/azure/azure-functions/functions-triggers-bindings#azure-portal-development )

我很困惑,因为我在模板中没有看到 CosmosDB 输入绑定(bind)的选择,因此没有看到任何提示。所以我尝试在 function.json 中手动添加代码,如下所示:

{
  "type": "cosmosDB",
  "name": "inputDocument",
  "databaseName": "DBName",
  "collectionName": "CollectionName",
  "connectionStringSetting": "CosmosDBConnect",
  "direction": "in",
  "Id": "myid",
  "partitionKey": "mypartitionkey"
}

当我尝试打开函数 C# 代码时,我看到错误“函数错误(MyFuncName):绑定(bind)类型“cosmosDB”未注册。请确保类型正确且绑定(bind)扩展名正确已安装。”

在此页面上,我看到 Azure Functions 版本 2 支持 CosmosDB 输入绑定(bind) ( https://learn.microsoft.com/en-us/azure/azure-functions/functions-triggers-bindings#supported-bindings )

最佳答案

更新

Azure CosmosDB 输入/输出绑定(bind)模板已可用,请不要忘记单击安装

enter image description here

<小时/>

您遇到了 Azure 门户可能计划在未来支持的内容。目前 v2 函数没有 cosmosdb 绑定(bind)选项,仅在 v1 中可用。已开通issue跟踪此功能支持。

解决方法是创建一个 Cosmos DB 触发器来安装 cosmosdb 扩展(实际上不需要创建触发器,只需使用它来获取安装提示),但我们仍然需要在 function.json 中手动编码来添加绑定(bind)。

enter image description here

关于azure - 无法在 Azure Functions V2 中注册 CosmosDB 绑定(bind)扩展,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51885661/

相关文章:

azure - 如何根据国家/地区限制 Azure 上托管的网站访问

Azure 网站部署 - 找不到用户 - 扩展代码 09004

c# - Azure Functions 绑定(bind)重定向

Azure 函数 (Python) 和 Blob 存储绑定(bind)错误

azure - CosmosDB - 正确的分区键

azure - Windows Azure 上的即用即付帐户包含哪种支持计划?

azure - 在命令行上检索函数应用设置包括已删除的项目

从 Azure DevOps 部署新的 ARM 后删除了 Azure Function 代码

azure - 具有包含 html 的大属性的元素的 Azure Cosmos DB 的性能

azure - 日期函数和选择 DocumentDB 中的前 N ​​个查询