I have to create a Flow that iterates over all files in a folder (DropBox, SharePoint, OneDrive etc) and merge them together into a single PDF file.
I can retrieve the list of files, and the Muhimbi PDF service has the ability to merge files into a single PDF. However, I ran into an issue that took a while to troubleshoot.
My tests indicate that Flow's 'For Each' capability does not execute each iteration in sequence. Instead it executes multiple iterations in paralllel. As a result it is not possible to feed the output of a previous cycle (the merged document so far) into the next cycle.
With the benefits of hindsight it is easy to reproduce.
For 4 iterations you'd expect a total run time of 4 minutes (due to the 1 minute delay). However, you'll find that all 4 iterations finish roughtly at the same time, after 1 minute in total.
Is this parallel processing a bug or a feature? if it is a feature, can we have a switch to force the iterator to run in sequence rather than in parallel?
With a recent change all flows run in sequence, not parallel. We will be adding an "opt-in" to the parallel behavior in the future.