【问题标题】:Azure function to read a blob schema用于读取 blob 架构的 Azure 函数
【发布时间】:2022-01-23 09:34:30
【问题描述】:

我目前正在制作一个 Azure 函数,该函数在上传新文件时读取 blob 架构。每当上传新文件时,我都会使用 Blob Trigger Function 来触发它,但是从那里我被卡住了。有人可以帮忙吗?

【问题讨论】:

    标签: python-3.x azure-functions


    【解决方案1】:

    以下是 Blod 触发器读取数据的示例代码。检查您的代码,这可能会帮助您解决问题。

    {
      "bindings": [
        {
          "queueName": "myqueue-items",
          "connection": "MyStorageConnectionAppSetting",
          "name": "queuemsg",
          "type": "queueTrigger",
          "direction": "in"
        },
        {
          "name": "inputblob",
          "type": "blob",
          "dataType": "binary",
          "path": "samples-workitems/{queueTrigger}",
          "connection": "MyStorageConnectionAppSetting",
          "direction": "in"
        },
        {
          "name": "$return",
          "type": "blob",
          "path": "samples-workitems/{queueTrigger}-Copy",
          "connection": "MyStorageConnectionAppSetting",
          "direction": "out"
        }
      ],
      "disabled": false,
      "scriptFile": "__init__.py"
    }
    

    这里是示例 python 代码。

    import logging
    import azure.functions as func
    
    
    # The input binding field inputblob can either be 'bytes' or 'str' depends
    # on dataType in function.json, 'binary' or 'string'.
    def main(queuemsg: func.QueueMessage, inputblob: bytes) -> bytes:
        logging.info(f'Python Queue trigger function processed {len(inputblob)} bytes')
        return inputblob
    

    有关完整信息,请查看此Blob Trigger 文档和Blob Trigger 输入绑定。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-12-11
      • 2018-01-08
      • 1970-01-01
      • 2021-12-18
      • 2018-07-30
      • 2016-10-12
      • 2020-12-28
      • 2020-02-23
      相关资源
      最近更新 更多