在 Python 中将文件从 Azure blob 读取到 Function App

Reading files from Azure blob into Function App in Python

我正在尝试使用 Function App 从 Python 中的 Azure blob 存储递归地从容器中读取多个相同类型的文件。但是如何使用 orchestrator host.json 中的绑定函数来完成,如下所示?应该在本地设置中进行哪些适当的更改,因为我已经提到 conn 字符串和 blob 的路径已经在同一位置?

{
  "scriptFile": "__init__.py",
  "bindings": [
    {
      "name": "context",
      "type": "orchestrationTrigger",
      "direction": "in"
    },
    {
      "name": "inputblob",
      "type": "blob",
      "dataType": "string",
      "path": "test/{file_name}.pdf{queueTrigger}",
      "connection": "CONTAINER_CONN_STR",
      "direction": "in"
    }
  ]
}

*test : 我的目录。

CONTAINER_CONN_STR : 已指定路径

另外,这样做时,在没有绑定的正常方法中,在将文件下载到本地系统时出错,如下所示:

Exception: PermissionError: [Errno 13] Permission denied: 'analytics_durable_activity/'

Stack: File "C:\Program Files\Microsoft\Azure Functions Core Tools\workers\python.8\WINDOWS\X64\azure_functions_worker\dispatcher.py", line 271, in _handle__function_load_request

func = loader.load_function(

how could that be done using binding functions in host.json of orchestrator as shown below? What appropriate changes should be made in local settings

您使用的配置看起来不错。更多信息可以参考这个Example.

Also, when doing so, in normal method without binding, gives error when downloading the files to local system as given below:

如果您您尝试打开一个文件,但您的路径是一个文件夹,或者如果您没有所需的权限,则可能会出现此错误。

您可以参考讨论类似问题的SO thread

参考资料: Set, View, Change, or Remove Permissions on Files and Folders | Microsoft Docs

您可以将触发器的状态保存在实体中,并在每次触发函数时检查相同的状态。只有当状态匹配时,函数才会处理文件,即上一个文件已经收到但没有处理。

请参阅 https://docs.microsoft.com/en-us/azure/azure-functions/durable/durable-functions-overview?tabs=csharp - 模式 #6:聚合器(有状态实体)