How can we stop the foreach activity based on some condition in adf without stopping the whole pipeline ?

Amar Agnihotri 921 Reputation points
2022-06-22T10:29:28.797+00:00

Hi,
I am performing foreach activity in adf and inside foreach i am performing if activity as shown -

213768-image.png

This is our lookup file being used in lookup activity -

213862-image.png

I defined some loop counters in lookup file and these are from 1 to 100. Now foreach activity is running for 100 times. Inside for each i am using if activity as
213853-image.png

This is the condition for each activity
213803-image.png

If the continuation token will be null then i want to stop that for each activity otherwise it will go to false section and perform some operation. Can anyone suggest where to mention that exit condition to break the foreach activity.

Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
10,196 questions
{count} votes

Accepted answer
  1. Suba Balaji 11,206 Reputation points
    2022-06-22T11:49:42.417+00:00

    Hi @Amar Agnihotri ,

    Thanks for the question and posting it on Microsoft Q&A platform.

    I can think of two options.

    1. You can use fail activity inside true part in the if condition so that the loop breaks and comes out when the Continuationtoken is null
    2. You can make use of an until activity, instead of a foreach. Reference

    Please revert for any further question on the same.

    Thanks

    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Amar Agnihotri 921 Reputation points
    2022-06-27T05:44:17.673+00:00

    hi @Suba Balaji and @AnnuKumari-MSFT

    The issue is resolved now. Actually i made the below change . I used empty function rather comparing with null and it is working now -
    215211-image.png

    215179-image.png

    Thanks to both of you for your support

    2 people found this answer helpful.