繁体   English   中英

在 Python Azure 函数中访问绑定表达式值

[英]Accessing binding expression values in Python Azure Function

是否可以从 Python Azure 函数中访问function.json绑定表达式的值?

这就是我想要做的:

function.json :

{
    "scriptFile": "__init__.py",
    "disabled": false,
    "bindings": [
        {
            "name": "myblob",
            "type": "blobTrigger",
            "direction": "in",
            "path": "samples-workitems/{folder1}/{folder2}/",
            "connection":"MyStorageAccountAppSetting"
        }
    ]
}

__init__.py

import logging
import azure.functions as func


def main(myblob: func.InputStream):
    logging.info('Python blob folder 1: %s', myblob.folder1)
    logging.info('Python blob folder 2: %s', myblob.folder2)

这个例子看起来应该可以工作,但实际上name变量似乎是硬编码的。

要将函数的返回值用作输出绑定的值,绑定的name属性应在function.json设置为$return

{
  "scriptFile": "__init__.py",
  "bindings": [
    {
      "name": "req",
      "direction": "in",
      "type": "httpTrigger",
      "authLevel": "anonymous"
    },
    {
      "name": "msg",
      "direction": "out",
      "type": "queue",
      "queueName": "outqueue",
      "connection": "AzureWebJobsStorage"
    },
    {
      "name": "$return",
      "direction": "out",
      "type": "http"
    }
  ]
}

有关更多信息,请检查绑定表达式

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM