如何在逻辑应用程序中从不同文件夹附加多个 blob?

发布于 2025-01-10 23:50:53 字数 1083 浏览 1 评论 0原文

您好,我在天蓝色逻辑应用程序中工作。我的 Blob 存储中有以下 Blob。

Predesign/guid/AdditionalDocument/somefile.ext
Predesign/guid/CalcOutput/somefile.ext
Predesign/guid/DataSheet/somefile.ext

输入图片此处描述

下面的步骤是列出我已给出示例路径 Predesign/guid 的 blob(在实际实现中,我会将 guid 视为动态)。在 guid 内部,我有多个子文件夹,如上所述

在此处输入图像描述

然后我有 sendemail 活动来发送带有附件的电子邮件。当我运行代码时,出现以下错误

{
  "status": 404,
  "message": "Specified blob PreDesign/1e36d504-7876-41b1-89b3-83d2132fa7c4/AdditionalDocumets/ does not exist.\r\nclientRequestId: fcb3f5d4-aca2-4c8e-bb8d-543d31fa9cb3",
  "error": {
    "message": "PreDesign/1e36d504-7876-41b1-89b3-83d2132fa7c4/AdditionalDocumets/ does not exist."
  },
  "source": "azurewebsites.net"
}

3 个文件夹“附加文档”、“计算输出”和“数据表”也会出现相同的错误。所以基本上我无法从这些不同的文件夹中获取内容。有人可以帮我附加不同文件夹中的多个文档吗?任何帮助将不胜感激。谢谢

Hi I am working in azure logic app. I have below blobs in my blob storage.

Predesign/guid/AdditionalDocument/somefile.ext
Predesign/guid/CalcOutput/somefile.ext
Predesign/guid/DataSheet/somefile.ext

enter image description here

Below step is to list blobs i have given sample path Predesign/guid(in real implementation i will take guid as dynamic). Inside guid i have multiple subfolders as mentioned above

enter image description here

Then I have sendemail activity to send email with attachments. When I run my code I get below error

{
  "status": 404,
  "message": "Specified blob PreDesign/1e36d504-7876-41b1-89b3-83d2132fa7c4/AdditionalDocumets/ does not exist.\r\nclientRequestId: fcb3f5d4-aca2-4c8e-bb8d-543d31fa9cb3",
  "error": {
    "message": "PreDesign/1e36d504-7876-41b1-89b3-83d2132fa7c4/AdditionalDocumets/ does not exist."
  },
  "source": "azurewebsites.net"
}

Same error occurs for 3 folders Additional Documets, CalcOutput and Data sheet. So basically I am not able to get content from these different folders. Can someone help me to attach multiple documents from different folders? Any help would be appreciated. Thank you

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

护你周全 2025-01-17 23:50:53

您收到此错误的原因可能是以下原因之一。

  1. 拼写错误的路径。
    如果您提到的路径是手动写入的,请尝试使用打开的文件框指向正确的文件夹。因为我可以看到你一开始就提到了 Predesign,但是在提到它的时候

  2. 连接失败
    您的逻辑应用连接器与存储帐户的连接可能出现故障。尝试创建与您的存储帐户的新连接。

有人可以帮我附加不同文件夹中的多个文档吗?

假设如果文件夹结构如下

Container  
|  
|  
____Directory 1  
|   ____Blob 1  
|   
|  
____Directory 2   
    ____Blob 2  
    ____File 3   

WAY-1

所示,您可以有 2 个 List blob 连接器并迭代它们。这是我的逻辑应用程序的屏幕截图供参考。

在此处输入图像描述

输出

Directory1 中的 Blob 列表

在此处输入图像描述

Directory2 中的 Blob 列表

WAY-2

您可以在 foreach 中使用 foreach 循环。这是我的逻辑应用程序的屏幕截图。

在此处输入图像描述

输出:-
在此处输入图像描述

在此处输入图像描述

这是我的逻辑应用程序的代码视图,

{
    "definition": {
        "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
        "actions": {
            "For_each": {
                "actions": {
                    "For_each_2": {
                        "actions": {
                            "Lists_blobs_in_Directory": {
                                "inputs": {
                                    "host": {
                                        "connection": {
                                            "name": "@parameters('$connections')['azureblob']['connectionId']"
                                        }
                                    },
                                    "method": "get",
                                    "path": "/v2/datasets/@{encodeURIComponent(encodeURIComponent('AccountNameFromSettings'))}/foldersV2/@{encodeURIComponent(encodeURIComponent(items('For_each_2')?['Path']))}",
                                    "queries": {
                                        "nextPageMarker": ""
                                    }
                                },
                                "runAfter": {},
                                "type": "ApiConnection"
                            }
                        },
                        "foreach": "@body('Lists_Directories_inside_Container')?['value']",
                        "runAfter": {
                            "Lists_Directories_inside_Container": [
                                "Succeeded"
                            ]
                        },
                        "type": "Foreach"
                    },
                    "Lists_Directories_inside_Container": {
                        "inputs": {
                            "host": {
                                "connection": {
                                    "name": "@parameters('$connections')['azureblob']['connectionId']"
                                }
                            },
                            "method": "get",
                            "path": "/v2/datasets/@{encodeURIComponent(encodeURIComponent('AccountNameFromSettings'))}/foldersV2/@{encodeURIComponent(encodeURIComponent(items('For_each')?['Path']))}",
                            "queries": {
                                "nextPageMarker": ""
                            }
                        },
                        "runAfter": {},
                        "type": "ApiConnection"
                    }
                },
                "foreach": "@body('Lists_Containers_in_root_folder')?['value']",
                "runAfter": {
                    "Lists_Containers_in_root_folder": [
                        "Succeeded"
                    ]
                },
                "type": "Foreach"
            },
            "Lists_Containers_in_root_folder": {
                "inputs": {
                    "host": {
                        "connection": {
                            "name": "@parameters('$connections')['azureblob']['connectionId']"
                        }
                    },
                    "method": "get",
                    "path": "/v2/datasets/@{encodeURIComponent(encodeURIComponent('AccountNameFromSettings'))}/foldersV2",
                    "queries": {
                        "nextPageMarker": "",
                        "useFlatListing": false
                    }
                },
                "runAfter": {},
                "type": "ApiConnection"
            }
        },
        "contentVersion": "1.0.0.0",
        "outputs": {},
        "parameters": {
            "$connections": {
                "defaultValue": {},
                "type": "Object"
            }
        },
        "triggers": {
            "manual": {
                "inputs": {
                    "schema": {}
                },
                "kind": "Http",
                "type": "Request"
            }
        }
    },
    "parameters": {
        "$connections": {
            "value": {
                "azureblob": {
                    "connectionId": "/subscriptions/<YOUR_SUBSCRIPTION_ID>/resourceGroups/<YOUR_RESOURCE_GROUP>/providers/Microsoft.Web/connections/azureblob",
                    "connectionName": "azureblob",
                    "id": "/subscriptions/<YOUR_SUBSCRIPTION_ID>/providers/Microsoft.Web/locations/northcentralus/managedApis/azureblob"
                }
            }
        }
    }
}

当我们要迭代的文件夹很多时,这些方法可能有点笨拙。在这种情况下,最有效的方法是使用 azure 函数。有关详细信息,您可以参考 获取所有文件夹中的所有文件列表

You might be receiving this error probably because of one of the following reasons.

  1. A misspelt path.
    If the path that you are mentioning is manually written Please try pointing the right folder using the open file box. Because I can see you mention Predesign at first but while mentioning it

  2. A connection failure
    You might be having a connection failure to your storage account from your logic app connector. Try creating a new connection to your storage account.

Can someone help me to attach multiple documents from different folders?

Suppose if the folder structure looks like below

Container  
|  
|  
____Directory 1  
|   ____Blob 1  
|   
|  
____Directory 2   
    ____Blob 2  
    ____File 3   

WAY-1

you can have 2 List blobs connectors and iterate through the same. Here is the screenshot of my logic app for reference.

enter image description here

output

List of Blobs in Directory1

enter image description here

List of Blobs in Directory2

enter image description here

WAY-2

You can use for each loop inside a for each. Here is the screenshot of my logic app.

enter image description here

output:-
enter image description here

enter image description here

Here is the code view of my logic app

{
    "definition": {
        "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
        "actions": {
            "For_each": {
                "actions": {
                    "For_each_2": {
                        "actions": {
                            "Lists_blobs_in_Directory": {
                                "inputs": {
                                    "host": {
                                        "connection": {
                                            "name": "@parameters('$connections')['azureblob']['connectionId']"
                                        }
                                    },
                                    "method": "get",
                                    "path": "/v2/datasets/@{encodeURIComponent(encodeURIComponent('AccountNameFromSettings'))}/foldersV2/@{encodeURIComponent(encodeURIComponent(items('For_each_2')?['Path']))}",
                                    "queries": {
                                        "nextPageMarker": ""
                                    }
                                },
                                "runAfter": {},
                                "type": "ApiConnection"
                            }
                        },
                        "foreach": "@body('Lists_Directories_inside_Container')?['value']",
                        "runAfter": {
                            "Lists_Directories_inside_Container": [
                                "Succeeded"
                            ]
                        },
                        "type": "Foreach"
                    },
                    "Lists_Directories_inside_Container": {
                        "inputs": {
                            "host": {
                                "connection": {
                                    "name": "@parameters('$connections')['azureblob']['connectionId']"
                                }
                            },
                            "method": "get",
                            "path": "/v2/datasets/@{encodeURIComponent(encodeURIComponent('AccountNameFromSettings'))}/foldersV2/@{encodeURIComponent(encodeURIComponent(items('For_each')?['Path']))}",
                            "queries": {
                                "nextPageMarker": ""
                            }
                        },
                        "runAfter": {},
                        "type": "ApiConnection"
                    }
                },
                "foreach": "@body('Lists_Containers_in_root_folder')?['value']",
                "runAfter": {
                    "Lists_Containers_in_root_folder": [
                        "Succeeded"
                    ]
                },
                "type": "Foreach"
            },
            "Lists_Containers_in_root_folder": {
                "inputs": {
                    "host": {
                        "connection": {
                            "name": "@parameters('$connections')['azureblob']['connectionId']"
                        }
                    },
                    "method": "get",
                    "path": "/v2/datasets/@{encodeURIComponent(encodeURIComponent('AccountNameFromSettings'))}/foldersV2",
                    "queries": {
                        "nextPageMarker": "",
                        "useFlatListing": false
                    }
                },
                "runAfter": {},
                "type": "ApiConnection"
            }
        },
        "contentVersion": "1.0.0.0",
        "outputs": {},
        "parameters": {
            "$connections": {
                "defaultValue": {},
                "type": "Object"
            }
        },
        "triggers": {
            "manual": {
                "inputs": {
                    "schema": {}
                },
                "kind": "Http",
                "type": "Request"
            }
        }
    },
    "parameters": {
        "$connections": {
            "value": {
                "azureblob": {
                    "connectionId": "/subscriptions/<YOUR_SUBSCRIPTION_ID>/resourceGroups/<YOUR_RESOURCE_GROUP>/providers/Microsoft.Web/connections/azureblob",
                    "connectionName": "azureblob",
                    "id": "/subscriptions/<YOUR_SUBSCRIPTION_ID>/providers/Microsoft.Web/locations/northcentralus/managedApis/azureblob"
                }
            }
        }
    }
}

These methods might be a bit clumsy when there are many folders that we want to iterate. In that case the most effective way is to use azure functions. For more information in this you can refer Get List of all files from all folder

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文