将多个Blob输入到Azure函数python中 [英] Input multiple blobs into azure function python

查看:60
本文介绍了将多个Blob输入到Azure函数python中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Python进行Azure功能.我试图读取两个Blob,一个被触发,一个静态Blob.

I'm working in python for a Azure function. I am trying to read in two blobs, one that is triggered, and a static blob.

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

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

我的绑定看起来像:

{
      "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文件的开头为:

And the init.py file starts with:

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)

推荐答案

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

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等之类的内容无法获取正确的值.但是实际上它们的数据是不同的(对象也不同).

In fact, you have already input the multiple blob, the problem comes from azure function blob binding metadata is not from the function host, so things such as blob name, blob length, uri etc cannot get correct values. But in fact their data is different (the objects are also different).

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

You can do something like below to test:

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获取元数据应该没有问题.

I think the problem is not on your side, it is a function design problem. There should be no problem using storage sdk to get metadata.

这篇关于将多个Blob输入到Azure函数python中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆