During some scenarios in Azure Data Factory, we may want to intentionally stop the execution of the pipeline. An example could be when we want to check the existence of a file or folder using Get Metadata activity. We may want to fail the pipeline if the file/folder does not exist.
To achieve this, we could use the Fail Activity. Invoking the Fail Activity ensures that the pipeline execution will be stopped. While the activity itself is very simple, the real utility comes from the way the control flow of the pipeline is designed. E.g., we may want to create multiple branches and conditions and have the Fail Activity in only one of the execution branches in the Pipeline, so that it is invoked only if the conditions preceding it are satisfied.
The added advantage of the Fail activity is that it can be used to surface user defined error codes and messages. Let’s have a look at the settings for Fail Activity:
As seen in the screenshot above, it is a very simple activity with just two settings:
Fail Message: This is the user-defined message to be surfaced in the logs
Error code: A user-defined numeric code to be surfaced
The custom error codes are helpful when searching the logs for messages that indicate that the Fail activity has been invoked.
Examples of Pipelines with Fail Activity will be discussed in future posts.