Reputation: 685
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
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
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
Upvotes: 0
Views: 725
Reputation: 8254
You might be receiving this error probably because of one of the following reasons.
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
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
you can have 2 List blobs
connectors and iterate through the same. Here is the screenshot of my logic app for reference.
output
List of Blobs in Directory1
List of Blobs in Directory2
You can use for each loop inside a for each. Here is the screenshot of my logic app.
output:-
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
Upvotes: 0