question

YasmeenMohmmad-5533 avatar image
0 Votes"
YasmeenMohmmad-5533 asked SharadTelkar-8230 commented

I have a requirement wherein a ForEach activity must break when an inner activity fails. How do i implement that.

I have created an adfv2 pipeline, lookup-->ForEach. I have implemented few activities inside the ForEach activity.
I want the ForEach activity to break( stop iterating) if any inner activity fails. How do i implement that.
Can someone please help me on this.

azure-data-factory
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

KranthiPakala-MSFT avatar image
1 Vote"
KranthiPakala-MSFT answered SharadTelkar-8230 commented

Hi @yasmeenmohmmad-5533,

Welcome to Microsoft Q&A forum and thanks for reaching out.

Unfortunately there is no out of box feature to break the ForEach activity iteration if any of the inner activities fails.

Here is an existing feature request submitted by another user in ADF user voice forum. Please feel free to up-vote and/comment on it to help increase the priority of the feature implementation. - https://feedback.azure.com/forums/270578-data-factory/suggestions/39673909-foreach-activity-allow-break

But here is a workaround which you could implement to can cancel the pipeline run when an inner activity of ForEach is failed.

For each activity inside ForEach declare a Success (green) and Failed(red) dependency, and when that particular activity fails then it enters Failed path where you use a Web activity in which you can call Pipeline Runs - Cancel API to cancel the current pipeline run by passing the current pipeline run ID. You can get the current pipeline run ID using this expression - @pipeline().RunId

88260-image.png

To cancel a pipeline run by its run ID, use this :

 POST https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataFactory/factories/{factoryName}/pipelineruns/{runId}/cancel?api-version=2018-06-01

runID = @pipeline().RunId

Hope this helps.



Please don’t forget to Accept Answer and Up-Vote wherever the information provided helps you, this can be beneficial to other community members.



image.png (16.4 KiB)
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @yasmeenmohmmad-5533,

Following up to see if the suggestion was helpful? Do let us know if you have further query. If the above solution answers your query, please do click “Accept Answer” and/or Up-Vote, as it might be beneficial to other community members reading this thread.

Thank you

0 Votes 0 ·

The web activity in ADF has a mandatory BODY field incase of a POST call. What are we supposed to put in the BODY field?

190643-image.png


0 Votes 0 ·
image.png (16.8 KiB)