how to stop the execution of a foreach loop in ADF when an activity fails

Viewed 2916

I have a scenario where I need to fail the complete pipeline when an activity fails inside the ForEach loop container in ADF V2. Don't want the loop to continue further.

I am using ExecutePipeline to call the pipeline which contain ForEach loop.

Please advice me in doing this.

Thanks, Nandini

2 Answers

In ADF, break loop in the ForEach activity is not supported now. You can add a If Condition activity in the ForEach activity to skip some steps in the loop.

For a situation where I wanted to break out of a loop and return to the parent flow when a Copy data Activity failed, I set the Copy data failure output path to execute two activities:

  • Set a condition that would stop looping (in my case # records written less than expected).
  • Force a failure with an invalid 'Set variable' (Set a string value to integer or anything that would trigger a fail).

When the Copy data activity fails, execution picks up in the parent flow on the Failure path of the loop.

Related