我想要一个 azure app-function,当一个新的 blob 添加到存储帐户中的指定容器中并将该 blob 传输到 Azure CosmosDB 中的指定数据库和容器时,该函数将被触发。我创建了一个应用程序功能并指定了必须监控的存储帐户和容器。在输出绑定中,我从门户选择了 Azure CosmosDB 作为我的输出绑定,并指定了我拥有的 CosmosDb 帐户的详细信息。我尝试执行它,但它说
The specified container does not exist
我无法理解错误与哪个容器有关,因此我勾选了 如果为真,则为 CosmosDB创建 Azure Cosmos DB 数据库和集合选项。它没有任何区别。所以我切换到高级编辑器来检查function.json,在那里我发现了“cosmosDB”的输出绑定类型和它下面的警告绿色下划线,它说明了
Value is not accepted. Valid values: ["documentDB"]
我将“cosmosDB”更改为“documentDB”并尝试再次执行它。这次有一个弹出窗口说明
Function (BlobTrigger) Error: The binding type(s) 'documentDB' are not registered. Please ensure the type is correct and the binding extension is installed.
Session Id: 10d62e7e360544009389504620f3506e
Timestamp: 2019-07-24T04:14:08.601Z
我按照https://docs.microsoft.com/en-us/azure/azure-functions/install-update-binding-extensions-manual添加扩展名并添加了以下扩展名
Microsoft.Azure.WebJobs.Extensions.DocumentDB Version 1.3.0
之后,我再次执行了 app-function,它再次向我显示关于 documentDB 未注册的相同弹出窗口,如果我在高级编辑器中将 documentDB 更改回 cosmosDb,它再次表示容器不存在。有人可以指出我哪里出错了。
更新 :
@Jack Jia 是的,我按照您说的相同程序进行了操作。为了重新确保,我重试了再次给我相同结果的过程。但在这个过程中,我意识到我面临的另一个问题。当我创建函数应用程序时,最初它说部署失败
{"code":"DeploymentFailed","message":"At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/arm-debug for usage details.","details":[{"code":"Unauthorized","message":"{\r\n \"Code\": \"Unauthorized\",\r\n \"Message\": \"The scale operation is not allowed for this subscription in this region. Try selecting different region or scale option.\",\r\n \"Target\": null,\r\n \"Details\": [\r\n {\r\n \"Message\": \"The scale operation is not allowed for this subscription in this region. Try selecting different region or scale option.\"\r\n },\r\n {\r\n \"Code\": \"Unauthorized\"\r\n },\r\n {\r\n \"ErrorEntity\": {\r\n \"ExtendedCode\": \"52020\",\r\n \"MessageTemplate\": \"The scale operation is not allowed for this subscription in this region. Try selecting different region or scale option.\",\r\n \"Parameters\": [\r\n \"default\"\r\n ],\r\n \"Code\": \"Unauthorized\",\r\n \"Message\": \"The scale operation is not allowed for this subscription in this region. Try selecting different region or scale option.\"\r\n }\r\n }\r\n ],\r\n \"Innererror\": null\r\n}"}]}
但过了一会儿,我在所有资源选项卡中找到了我创建的函数应用程序,然后我继续。也许这就是我遇到这样一个问题的原因。但是为了创建函数应用程序,我参考了https://docs.microsoft.com/en-au/learn/modules/chain-azure-functions-data-using-bindings/3-explore-input-and-output-binding -types-portal-lab明确指出印度中部是一个有效的沙箱位置。如果您能在这里指导我,那就太好了。