python - 在 Python Azure 函数中访问绑定表达式值
问题描述
是否可以function.json
从 Python Azure 函数中访问绑定表达式的值?
这就是我想要做的:
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
属性应设置为$return
in function.json
。
{
"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"
}
]
}
有关更多信息,请检查绑定表达式
推荐阅读
- c++ - 通过 std::shared_ptr 使用 Rcpp 和 RcppParallel 的线程安全函数指针
- node.js - Postman works but Fetch doesn't. What am i doing wrong?
- ansible - 使用 yaml 将单个主机添加到 ansible 塔
- r - 用handsontable优先渲染闪亮
- spring-boot - 使用feign客户端如何处理大数据
- sql - 尝试通过 SSMS 从暂存服务器 (Azure) 显示表内容时出错
- postgresql - Placeholder in PostgreSQL sql file
- c# - Telerik RadEditor 未获取当前内容
- git - GIT:gclient 同步错误“需要一个修订版”
- swift - get substrings from string