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

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

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


This is our lookup file being used in lookup activity -


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

This is the condition for each activity

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.
6,268 questions
{count} votes

Accepted answer
  1. answered 2022-06-22T11:49:42.417+00:00
    Subashri Vasudevan 4,296 Reputation points

    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.


1 additional answer

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

    hi @Subashri Vasudevan 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 -


    Thanks to both of you for your support