我想在我的存储上创建一个 Blob,其动态路径取决于持久功能事件的第一个参数。当访问参数有效时,路径会包含引号。在Python中。
我的存储中生成的文件被命名为 data_"someid".npz。如何在名称中不包含引号的情况下执行此操作?
我的 json 看起来像这样,注意包含 {userid} 的输出路径
{
"scriptFile": "__init__.py",
"bindings": [
{
"name": "userid",
"type": "activityTrigger",
"direction": "in"
},
{
"name": "outfile",
"type": "blob",
"dataType": "binary",
"path": "azfuntest/data_{userid}.npz",
"connection": "AzureWebJobsStorage",
"direction": "out"
}
]
}
来自 init.py:
async def main(userid: str, outfile: func.Out[func.InputStream]) -> str:
...
从我的 Orchestrator_function 调用它:
context.call_activity("MyActivity", "someid")
功能工具:V3
pip azure-function-blob:12.8
最佳答案
在函数定义中,您将 userid 作为 str 传递,因此它将被视为 str,此外,您还将“userid”作为绑定(bind)中的名称传递,因此怀疑引号是否正在更新。相反,您可以遵循以下格式。
{
"bindings": [
{
"name": "info",
"type": "httpTrigger",
"direction": "in",
"webHookType": "genericJson"
},
{
"name": "blobContents",
"type": "blob",
"direction": "in",
"path": "strings/{BlobName}",
"connection": "AzureWebJobsStorage"
},
{
"name": "res",
"type": "http",
"direction": "out"
}
]
}
这里名称不同,路径中传递的参数也不同。 BlobName 应从函数传递。
此外,如需了解更多信息,请查看documentation of bindings了解如何传递值和处理绑定(bind)错误
关于python - 访问 ActivityTrigger 时,Azure Functions Blob 输出绑定(bind)会在路径中添加引号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68634604/