首页 文章

无法在Azure Functions V2中注册CosmosDB绑定扩展

提问于
浏览
3

我正在尝试添加一个带有CosmosDB输入绑定的新函数(Http Trigger) .

在Azure Functions Version 2中阅读有关输入绑定的手册我看到我需要注册我的binging扩展(https://docs.microsoft.com/en-us/azure/azure-functions/functions-triggers-bindings#register-binding-extensions),而azure portal应该向我显示一些注册提示(https://docs.microsoft.com/en-us/azure/azure-functions/functions-triggers-bindings#azure-portal-development

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

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

当我尝试打开我的函数C#代码时,我看到错误 "Function error(MyFuncName): The binding type(s) 'cosmosDB' are not registered. Please ensure the type is correct and the binding extension is installed."

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

1 回答

  • 2

    Update

    Azure CosmosDB输入/输出绑定模板已经可用,请不要忘记单击 install .

    enter image description here


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

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

    enter image description here

相关问题