在Azure函数中输入多个blob

2024-06-10 07:02:50 发布

您现在位置:Python中文网/ 问答频道 /正文

我希望在Azure存储中的同一容器/目录下接收多个文件时触发作业。假设我收到了两个文件: -mycontainer/上载/文件/文件.rtf -mycontainer/上载/文件/文件.txt在

我想要的作业应该在这两个文件都出现时触发。所以我开始定义如下绑定:

{
  "scriptFile": "__init__.py",
  "bindings": [
    {
      "name": "myitem",
      "type": "queueTrigger",
      "direction": "in",
      "queueName": "myfiles",
      "connection": "StorageConnectionString"
    },
    {
      "name": "inputRtf",
      "type": "blob",
      "direction": "in",
      "path": "uploads/files/{blobname}.rtf",
      "connection": "StorageConnectionString"
    },
    {
      "name": "inputTxt",
      "type": "blob",
      "direction": "in",
      "path": "uploads/files/{blobname}.txt",
      "connection": "StorageConnectionString"
    },
    {
      "name": "outputRtf",
      "type": "blob",
      "direction": "out",
      "path": "output/{blobname}.rtf",
      "connection": "StorageConnectionString"
    },
    {
      "name": "outputTxt",
      "type": "blob",
      "direction": "out",
      "path": "output/{blobname}.txt",
      "connection": "StorageConnectionString"
    }
  ]
}

为了简单起见,假设python代码只将.txt文件的内容复制到output容器中,.rtf文件也是如此。我真的不明白queueTrigger是如何工作的,所以我很确定我的配置看起来不对


Tags: 文件pathnameintxtoutputtype作业
1条回答
网友
1楼 · 发布于 2024-06-10 07:02:50

你必须确认你的功能所需的所有文件都存在,然后触发你的功能。输入绑定无法独立完成。在

相反,您可以使用一个Event Grid Triggered函数,该函数将为上载的每个blob以及检查实际函数所需的其他文件是否存在的每个事件触发。在

如果不是,只返回,但是如果所有文件都确实存在,则触发实际函数。在

您可以使用存储队列消息(使用binding)触发实际函数,该消息包含blob输入绑定所需的文件名详细信息。在

有关使用队列触发器绑定和Blob输入绑定的示例,请检查blob input binding docs。在

相关问题 更多 >