python - 访问 ActivityTrigger 时,Azure Functions Blob 输出绑定(bind)会在路径中添加引号

标签 python azure azure-functions

我想在我的存储上创建一个 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/

相关文章:

azure - 访问 Azure Devops YAML Pipeline 中的容器资源变量

Python:SymPylambdaifyabs 与 NumPy 一起使用

python - 在 pandas 系列上使用 apply 方法获取 TypeError 'Series' 对象是可变的,因此无法对其进行哈希处理

azure - 从 Azure 服务读取 STOMP 源

Azure KQL - 在时间表之上创建总平均线

Python + Azure 存储队列 receive_messages()

Azure Blob Storage V2,升级后来自 Azure Function App 的异常 API 调用

azure - 您可以将流量管理器与 blob 存储或 Azure 功能结合使用吗

python - 在 scipy.spatial.Delaunay 中 find_simplex() 方法返回什么?

python - 通过执行依赖于多个索引的操作来创建列表 - python