Azure Logic App — split on and for each

Michal Molka
3 min readMar 15, 2024

--

This post is a continuation of this topic: Azure Logic Apps — BLOB to CosmosDB

A recap: A workflow used in the previous post uses a split on approach which creates a separate workflow for every file. So, there is no need to use a for each loop if more files are provided.

What is Split On and how does it work? Let’s assume that the trigger detects that there are 5 files to process. If you simply provide an array of files metadata, then the workflow from the previous post won’t fly. According to the solution architecture there is a simple sequence, one file expected, but the solution works. Why? If you go to the trigger settings, there is a Split On section. As you see, here is a @triggerBody() array provided . Every element of the array contains metadata for one file and every array element is processed by a different workflow.

And indeed, five files are uploaded, and five runs are registered.

Let’s consider another approach. Let’s assume that we don’t want to run a separate logic app for every file. We want to refine all detected files in one run.

The first step is to turn the Split On off. Then we can redesign the workflow.

The trigger is intact. All further steps have to be placed inside a For each loop.

We provide a list of files directly into the For each step. List of Files equals triggerBody()

A Get blob content (V2) step takes List of files Path equals items(‘For_each’)?[‘Path’]

When there is more than one file uploaded the logic app is run only once.

When we look at the run details, then according to expectations the For loop indicates that two files have been processed.

--

--

Michal Molka

Architect | Azure | Power BI | Fabric | Power Platform | Infrastructure | Security | M365