Published on

November 15, 2018

Implementing Email Notifications in Azure Data Factory

When working with data transformation processes in Azure Data Factory, it is crucial to have control and visibility over any errors that may occur. One effective way to stay informed about these errors is through email alerts. Although Azure Data Factory does not provide an out-of-the-box functionality for sending emails, we can leverage the Web Activity task in ADF to integrate a custom Azure Logic App that enables email notifications.

In this blog post, we will explore how to create ADF Notification Logic Apps in Azure to implement email notification functionality in two possible cases:

Case A – Email Notification for a Failed Copy Data Task

In this scenario, we want to receive an email notification specifically when a Copy Data task fails. To achieve this, we need to follow these steps:

  1. Open the pipeline “Load data into SQL” container and add a Web Task for the failed event from the “Copy Data Blob to SQL” activity task.
  2. Copy the HTTP URL from the Logic App in the Azure portal and paste it into the Web task.
  3. Add a new header with the following values:
    • Name: Content-Type
    • Value: application/json
  4. Define the body of the POST request with the necessary data elements for the JSON construction of the Logic App. This includes:
    • DataFactoryName: @{pipeline().DataFactory}
    • PipelineName: @{pipeline().Pipeline}
    • ErrorMessage: @{activity(‘Copy Data Blob to SQL’).Error.message}
    • EmailTo: @{pipeline().parameters.var_email_address}

Case B – Email Notification for Logged Events with Failed Status

In this case, we want to generate email notifications for logged events with a Failed status. To achieve this, we need to follow these steps:

  1. Open the pipeline “Logging to SQL” container and add another container to check if the logged event has a Failed status using the following conditional expression: @equals(split(item(),’|’)[12], ‘Failed’)
  2. Add two activity tasks within this Condition activity to support email notifications.
  3. Similar to Case A, copy the HTTP URL from the Logic App in the Azure portal and paste it into the Web task. Add the same new header.
  4. Define the body of the POST request with the necessary data elements for the JSON construction of the Logic App. This includes:
    • DataFactoryName: @{pipeline().DataFactory}
    • PipelineName: @{pipeline().Pipeline}
    • ErrorMessage: @{variables(‘var_activity_error_message’)}
    • EmailTo: @{pipeline().parameters.var_email_address}

By following these steps, you can now receive email notifications when something fails in your Azure Data Factory pipeline. This provides a timely and effective way to address any issues that may arise during the data transformation process.

Remember to test the email notification functionality by intentionally causing a failure, such as temporarily changing the name of a table used as a destination in the Copy Data task.

Thank you for reading this blog post on implementing email notifications in Azure Data Factory. Stay tuned for more SQL Server-related content!

Click to rate this post!
[Total: 0 Average: 0]

Let's work together

Send us a message or book free introductory meeting with us using button below.