当前位置: 首页 > 知识库问答 >
问题:

每当将Blob添加到容器中时,将数据从Blob存储发送到cosmosDB时,Azure应用函数的绑定类型存在问题

刘弘济
2023-03-14

我想要一个azure应用程序功能,当一个新blob被添加到存储帐户中的指定容器中,并将该blob传输到azure CosmosDB中的指定数据库和容器时,该功能将被触发。我创建了一个应用程序函数,并指定了必须监视的存储帐户和容器。在输出绑定中,我从门户选择Azure CosmosDB作为我的输出绑定,并指定了我拥有的CosmosDB帐户的详细信息。我试着执行,但它说

The specified container does not exist

我无法理解错误是关于哪个容器的,所以我勾选了If true,为CosmosDB创建了Azure Cosmos DB数据库和集合选项。这没什么区别。所以我切换到高级编辑器来检查功能。在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

在那之后,我再次执行的应用程序功能,它再次显示mye相同的弹出窗口关于文件数据库未注册,如果我改变回文件数据库的cosmosDb在高级编辑器它再次说容器不存在。有人能指出我哪里出错了吗?

更新:

@杰克·贾:是的,我遵循了你说的同样程序。为了重新测试,我重新尝试了这个过程,再次得到了同样的结果。但在这个过程中,我意识到了我面临的另一个问题。当我创建功能应用程序时,最初它说部署失败

{"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明确指出印度中部是一个有效的沙盒位置。如果你能在这里指导我,那就太好了。

共有1个答案

劳英华
2023-03-14

刚刚测试(使用CosmosDBSQLAPI),并获得了成功。您能进一步检查集成设置吗?

您可以从CosmosDB概览中获取数据库名称和集合名称:

并在函数应用中设置正确的值:

功能代码:

public static void Run(Stream myBlob, string name, out dynamic outputDocument, ILogger log)
{
    log.LogInformation($"C# Blob trigger function Processed blob\n Name:{name} \n Size: {myBlob.Length} Bytes");
    outputDocument = new { datainfo = name, id = Guid.NewGuid(), contentLength = myBlob.Length };
}

每次我将一个文件上传到目标blob容器时,都会向cosmos DB添加一个新文档。

 类似资料:
  • 我想使用Python中的Azure函数将JSON数据作为. json文件上传到Azure存储Blob。 因为我使用的是Azure函数,而不是实际的服务器,所以我不想(也可能无法)在本地内存中创建一个临时文件,并使用Azure blob存储客户端库v2将该文件上载到Azure blob存储。1对于Python(这里有参考链接)。因此,我想为Azure函数使用输出blob存储绑定(这里有参考链接)。

  • 我有一个EventHubTrighted函数app。下面是方法签名的代码示例: @functionname(“foo”)@storageaccount(“foostorageRead”)public HttpResponseMessage run(@httptrigger(name=“req”,methods={httpmethod.post},authLevel=authorizationlev

  • 我正试图从azure blob存储中加载数据到delta lake。我正在使用下面的代码段 storage_account_name=“xxxxxxxxdev”storage_account_access_key=“xxxxxxxxxxxxxxxxxx” file_location=“wasbs://bicc-hdspk-eus-qc@xxxxxxxxdev.blob.core.windows.n

  • Azure函数存储帐户Blob容器触发器 在我们的一个用例中,我正在为具有以下条件的存储帐户容器中的任何活动寻找Azure函数触发器 < li >具有特定命名约定的容器(名称如xxxx-input) < li >它应该自动检测是否创建了新的容器(具有特定的命名约定) < li>

  • 我试图将一个Azure Blob存储容器挂载到一个DataBricks实例上,虽然挂载确实有效,但它似乎没有使用存储容器。 我在这里漏掉了什么?

  • 我最近在学习如何阅读