SQLServerCentral Article

Working with Fail Activity in Azure Data Factory



In this article, we will talk about a newly introduced activity in Azure Data Factory, which is the fail activity. The fail activity is very useful to stop or fail the pipeline at the specified point. For example, a lookup activity might return no data or a switch activity executes the default block. We can use fail activity in such scenarios and customize both error messages and error codes.

Fail Activity

Let's go to the author page in Azure Data Factory:

Create a new pipeline from the factory resources menu options:

The Fail activity is available is in the general section of the activities :

Let's take a look at the Fail activity settings below:


In the settings tab of the fail activity, it has two boxes:

  1. Fail message - The error message provided in the fail activity. It can be a dynamic message that's evaluated at run time.
  2. Error code - The error code for the failed message categories. It can also be a dynamic message that's evaluated at run time.

The pipeline developer needs to provide the error message and the error code.

For this example, we will use a switch activity in the pipeline. This pipeline has a parameter COLOUR with default value YELLOW. The switch activity has three case statements Default, Red and Green.  In Red and Green case statements,each of them has respective activities:

Inside the default case statement of the switch activity, I added the fail activity with the configurations as below:

  • Fail message - Invalid input
  • Error code - 101

Let's run the pipeline with default value Yellow in the parameter:

Now the Switch activity failed as expected and the Fail activity inside the default case statements executed :

We will check the error detail of the fail activity:

In the error details window, it showed error code 101 and the error message Invalid input which we provided in that fail activity:

Let's go to the monitor page of the Azure data factory, here we can find the same error message, invalid input, from the fail activity:


In this article, we discussed fail activity in the Azure data factory. We can use fail activity whenever we want to fail the ETL at some point in the pipeline.


You rated this post out of 5. Change rating




You rated this post out of 5. Change rating