python - 将多个 blob 输入到 azure 函数 python 中

标签 python azure azure-functions blob

我正在使用 python 来实现 Azure 函数。我正在尝试读取两个 blob,一个是触发的,另一个是静态 blob。

当我读入它们时,两个 blob 都指向触发的 blob(URI 相同)。如何正确输入和使用两个blob?

我的绑定(bind)如下所示:

{
      "name": "techdatablob",
      "type": "blobTrigger",
      "direction": "in",
      "path": "path1/{name}",
      "connection": "example"
    },
    {
      "name": "crmdatablob",
      "type": "blob",
      "direction": "in",
      "path": "path2/data.xlsx",
      "connection": "example"
    },
    {
      "name": "outputblob",
      "type": "blob",
      "direction": "out",
      "path": "path3/out.xlsx",
      "connection": "example"
    }

init.py 文件开头为:

def main(techdatablob: func.InputStream, crmdatablob: func.InputStream, outputblob: func.Out[func.InputStream]):
    logging.info(f"Python blob trigger function processed blob \n"
                 f"Name: {techdatablob.name}\n"
                 f"Blob Size: {techdatablob.length} bytes")

    print(techdatablob.uri)
    print(crmdatablob.uri)

最佳答案

When I read them in, both blobs point to the triggered blob (URI is the same). How can input and use two blobs correctly?

事实上,您已经输入了多个 blob,问题来自于 azure 函数 blob 绑定(bind)元数据不是来自函数主机,因此 blob 名称、blob 长度、uri 等内容无法获取正确的值。但实际上他们的数据是不同的(对象也不同)。

您可以执行如下操作来测试:

import logging

import azure.functions as func


def main(techdatablob: func.InputStream, crmdatablob: func.InputStream) -> None:
    logging.info("-----"+techdatablob.read().decode('utf-8'))
    logging.info("-----"+crmdatablob.read().decode('utf-8'))

检查此错误页面:

https://github.com/Azure/azure-functions-python-worker/issues/576

我觉得问题不在你这边,是功能设计的问题。使用storage sdk获取元数据应该没有问题。

关于python - 将多个 blob 输入到 azure 函数 python 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66129665/

相关文章:

azure - Azure Functions 应用服务中的最大突发和最大扩展限制之间有什么区别

python - Pyomo 时间相关模型?

python - 使用 python 和 pandas 回测交易策略 - 一次仅识别一个未平仓头寸

python - 如何在 Matplotlib 中设置默认颜色图

c# - Azure函数: how to efficiently send batch of messages to Service Bus using bindings?

c# - 从 Azure Blob 存储读取数据时 OpenReadAsync() 出现奇怪的结果

python - pandas 绘制一个特定的列作为 x 轴和 y 轴?

azure - 我可以在 BotBuilder 中使用 PubNub 而不是 DirectLine 吗?

azure - Azure Durable Functions 中的依赖项调用失败

azure - 新的 Azure Function App 中意外提供了 SSL 证书