将多个blob输入azure函数python

2024-06-16 09:29:07 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在python中为Azure函数工作。我试图读入两个blob,一个是触发的,一个是静态的

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

我的绑定看起来像:

{
      "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)

Tags: pathnameinexampletypeconnectionoutxlsx
1条回答
网友
1楼 · 发布于 2024-06-16 09:29:07

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绑定元数据不是来自函数主机,因此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获取元数据应该没有问题

相关问题 更多 >