I currently have a logic app that runs on a schedule. It tries to look for files in a blob in a given storage account. Then processes the file(s) via a function app. After processing the Logic app sends an email that the files have been processed. However, if there are no files in a container then I don’t want the function to fire or send an email. so before anything in the workflow happens I want to check for a count of container records > 0. I can not find a connector/action that can give me just the count without having to loop through the whole blob. Is there a workflow connector that will give a list blob count>
2
Answers
To get count of blobs in a container you can use below design:
Then inside Foreach:
Then in Compose, you can check the variable value which contains count:
Full Design:
Output:
So, in next action use condition, In condition if var > 0 then you can do next actions:
You don’t need to loop through the list to get the count of the blobs. You can just check if
@length(body('Lists_blobs_(V2)')?['value'])
equals 0:Please note that if you want blobs from subfolders to be excluded, you might need to filter the
@body('Lists_blobs_(V2)')?['value']
array accordingly.Also, although not directly related to your question, keep in mind that if you have more than 5,000 blobs in the list, to be able to process all of them you’ll need to follow the OData
nextLink
s.