skip to Main Content

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


  1. How to get a count of blobs in a storage container in a logic app work flow

    To get count of blobs in a container you can use below design:

    enter image description here

    • You can set recurrence at 1 second or at 1 hour , 2 hrs or your favorable period time.
    • Initialize integer variable with 0.
    • You need to keep Flat Listing to get blobs inside the folders too.

    Then inside Foreach:

    • Checking IsFolder isequal to false to remove folder names.
    • Then increment variable.

    enter image description here

    Then in Compose, you can check the variable value which contains count:

    enter image description here

    Full Design:

    enter image description here

    Output:

    enter image description here

    So, in next action use condition, In condition if var > 0 then you can do next actions:

    enter image description here

    Login or Signup to reply.
  2. 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:

    enter image description here

    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 nextLinks.

    enter image description here

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search