Break foreach loop activity based on output of webhook activity in Azure data factory

srk 1 Reputation point
2021-07-24T15:06:53.98+00:00

I am passing some records through foreach loop activity to webhook activity in ADF

In Webhook activity I am calling Rest API to get the status code back so I get different status codes like 202, 400, 500 for each record. We usually receive 500 code when the API service is down

If I,m passing 5 records to foreach loop, the first request will be sent to Webhook and we get status code 500, loop has to break when we recieve status code 500 for the first record which means rest of the 4 records should not be passed to webhook activity. Can anyone please guide me how to achieve this?

Many thanks for your help in advance

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

1 answer

Sort by: Most helpful
  1. Ryan Abbey 1,181 Reputation points
    2021-07-25T19:53:57.177+00:00

    Wrap your call in an IF, assign a variable for the return status code initialised to 0 (or whatever) and a second variable that identifies first row (set to True/1 whatever). Have if condition as Status Code != 500 or Row > 1. Overwrite the status code variable with return from call, increment (or whatever) the first row variable

    0 comments No comments

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.