Azure Functions Blob 输出绑定在访问 activityTrigger 时在路径中放置引号

Azure Functions Blob Output binding puts quotation marks in path when accessing activityTrigger

我想根据持久函数 Activity 的第一个参数使用动态路径在我的存储上创建一个 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”作为名称传递,因此疑问引号正在更新。相反,您可以遵循以下格式。

{
  "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 以了解如何传递值和处理绑定错误