I want to fail my Azure Data Factory pipeline if certain conditions occurs. For example when a lookup doesn't return any records for my ForEach loop. Which setting or activity can I use for that?
Fail Activity |
Solution
In the past we often used a Stored Procedure Activity with a RAISERROR query in it to throw a custom message. However a while ago Microsoft released the Fail activity to accomplish this in a better way (at the moment of writing still in public preview).
For this example we have a Lookup activity and a ForEach activity that loops through the records from the lookup. If the Lookup activity doesn't return any records then the ForEach activity just won't loop. Now add an If Condition activity between those two and use an expression to test the record count: @equals(activity('myLookup').output.count, 0)
Add If Condition |
Now go to the True part of the If Condition and add the Fail activity. Add the custom error message with a made up error code.
Fail Activity |
Now make sure query in the lookup doesn't return any records for this test and then trigger the pipeline.
Oops the pipeline fails (on purpose) |
Conclusion
In this blog post you learned how to fail your pipelines on purpose with the new Fail Activity. You could for example also use it after an error handler step (which will handle the error and therefore not fail your pipeline) to force fail the pipeline.
Force Fail after error handler |
No comments:
Post a Comment
All comments will be verified first to avoid URL spammers. यूआरएल स्पैमर से बचने के लिए सभी टिप्पणियों को पहले सत्यापित किया जाएगा।