skip to Main Content

So, Azure Workflow editor does me the "courtesy" of creating a For Each iterator when I pull the list of files in a blob folder. But! What I want is a For One action. Is there an add action that allows me to just process one of the files in the list that results from the prior action?

I'd like this thing to be changed to a For One, instead of a For Each.  I only want to process one.

2

Answers


  1. Chosen as BEST ANSWER

    Alright, so as of this moment, I'm confident that the answer to this question is No. Rithwikbojja stated that above in the comments, and my work on this brings me to agreement. There are not "state of blob list" functions available like exists_in_list or length_of_list or list_is_empty. All functions provided apply to a single item within the list.

    Oh, and terminate functions don't run within loops for some reason. So you'll loop through everything, every time.

    That said, you can do plenty of loops through the list of blobs, one after the other, in order to gain the information you need to eventually perform a process on all of the objects that only has an effect on one. In my case all I needed to do was to find a file by name and, if it doesn't exist, rename one of the blob files to that name.

    So for me this was the following --

    1. Get the list of blobs.

    2. Loop through the list of blobs. 2a. On each pass of the loop, determine if the name of the blob is the name I'm looking for, true or false. 2b. On each pass of the loop, copy the name of the current blob into a variable.

      . . . The result of this loop is that at some point a "file found" variable gets set to true if the file exists. The variable is initialized to false before the loop, gets set to true in one pass if the file name is found.
      The name of each file gets written into a "file name to process" variable. It's set each pass through the loop, ending up with the last file name in the list as its final value. Sigh . . . not sweet programming, but it gets all my bs set up for the real pass. So far I've done no real work, just gotten stuff set up.

    3. Loop through the list of blobs again. 3a. On each pass, IF the current blob has the "file name to process" AND "file found" is false, then copy that blob to the target file name, make a copy to an archive folder, and delete that blob from the folder. 3b. If the conditions in 3a are not met, do nothing.

    . . . That is, loop through the entire set no matter what, doing nothing, except for that one place (last pass through the loop) where the file name matches, and only then when the target file name doesn't exist.

    This reminds me of programming in assembly 40 years back. Everything is atomic, everything is done in its most elementary form. For the life of me I don't understand why Microsoft hasn't fleshed this out with additional functions. It seems designed to force us hourly workers to bill more hours to our customers. Sure am glad I'm paid by the hour for this work. My old system made functions like this super-easy, perhaps half a dozen lines of code.


  2. Azure Workflow — I want to do something to only one file in a blob folder, when there may be many

    Here, you have to use for each for sure and then use condition inside it as below design:

    enter image description here

    Current item is the blob which you want to work with. Here, i have used http trigger, you can use recurrence in place of it. Alternatively, Inside for each you can set the blob to a variable and then you can process that variable outside of it also.

    Output:

    If blob name matches:

    enter image description here

    If it does not match:

    enter image description here

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