How to stop ForEach activity if previous itertion fails in ADF/Synapse pipeline

heta desai 357 Reputation points
2022-06-13T19:20:26.183+00:00

I am trying to pull multiple tables from a Azure SQL Database . When data is loaded to its destination I am calling an SP that will update the status of a table to Success. Using ForEach activity multiple tables are puling. But, While pulling one table if any activity in ForEach fails than after executing fail path the ForEach loop should exit. 210995-pipeline.jpg

As shown in the attached image if copy activity fails than after executing its Fail path which includes activities such as SetPipelineObjectStatus, AuditPipeline and SetPipelineObjectStatusToDefault, ForEach loop should stop means new Iteration should not be started and Pipeline should be failed.

Azure Synapse Analytics
Azure Synapse Analytics
An Azure analytics service that brings together data integration, enterprise data warehousing, and big data analytics. Previously known as Azure SQL Data Warehouse.
5,172 questions
Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
11,211 questions
{count} vote

2 answers

Sort by: Most helpful
  1. Nasreen Akter 10,811 Reputation points
    2022-06-13T19:50:10.413+00:00

    Hi @Anonymous ,

    I think Fail activity might be able to help you here. :)

    210964-image.png

    1 person found this answer helpful.
    0 comments No comments

  2. Nandan Hegde 34,021 Reputation points MVP
    2022-06-14T04:03:24.87+00:00

    Hey,
    @Nasreen Akter , based on my understanding the Fail activity would fail for that iteration but the FOR each activity would take it to the net iteration.

    @Anonymous : for you to stop the iterations and pipeline if anything fails within the iteration, you would need to use web activity to disable the ADF pipeline execution via REST API.
    Below link is somewhat helpful w.r.t disabling the trigger, you can follow the similar approach to disable the execution:
    https://learn.microsoft.com/en-us/answers/questions/160681/how-to-automatically-stop-trigger-in-azure-data-fa.html

    Note: This is crude way to exit the loop as it would ensure that your pipeline execution is terminated and no other activities post that loop would be executed even if you wanted it to execute

    1 person found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.