Azure Logic Apps is a leading integration platform as a service (PaaS) that is used to automate tasks, workflows, etc. It helps in creating and designing automated workflows that can integrate services, systems and applications.
Problem
To know the status of Azure Data Factory pipeline it’s necessary to log on to Azure Data Factory every day. What if you forget to look at the pipeline monitor for a week and the pipeline has failed. This may lead to have outdated/incorrect data for that week. Even if the status is updated on to configuration table or history table, the user has to check the table each and every time the data is loaded. This leads to manual efforts.
Solution
This document will help to develop an automatic email that alerts the user when a pipeline fails. First, Azure Logic App has to be created and then it has to be configured with Azure Data Factory. The reason why Azure Logic App is used is that Azure Data Factory does not have any activity to send emails. It is possible to activate standard alerts (emails) in ADF, but these do not create any clarity, what a custom email does.
SETUP AZURE LOGIC APPS
- Create a Consumption Logic App.

- Use a Blank template.
- You will be able to trigger an e-mail sending whenever a request is sent to the app following a failure of the ADF pipeline using workflow designer.
- You need to configure the first operation so that it triggers the email sending “When a http request is received”: from the right window, start typing “request” in the search bar and select the “When a http request is received” icon:

- Click the Save button to generate the HTTP POST URL

- Copy the generated HTTP POST URL.

Before going on with the Logic App’s workflow design, you need to go back to ADF pipeline, to add a web activity that will trigger the HTTP request in case of failure.
AZURE DATA FACTORY CONFIGURATION
- Create a pipeline, from the activities pane, drag and drop a web activity to the pipeline, name it accordingly and connect it to set variable which captures the data from lookup activity.
- In the Lookup activity settings connect the source dataset to the config table and write below query as displayed.
select cast((select concat(‘Source Table Name: ‘,source_table_name,’ | LMD: ‘,LMD,’ | Status: ‘,success_failure,’ | Error Msg: ‘,ErrorMsg) as li from [dbo].[metadatatable] where success_failure = ‘failure’ for XML Raw(”), ROOT(‘ol’), ELEMENTS, TYPE) as nvarchar(max)) as output_result

- In set variable activity, create a new variable name it as result and the value is as below.
@string(activity(‘Lookup1’).output.value[0].output_result)

- In the web activity’s settings tab, paste the URL that was generated in the Azure Logic App workflow and select the POST method:

- To be able to have dynamic content within the e-mail, edit the web activity’s body (which content will be passed to the logic app in later step).
- To edit the body, select the ADD dynamic content option. The web activity’s body should be in a json format, as following:
{
“Subject”:”Pipeline Failure Notification”,
“Message”:”Please review your ADF pipeline!”,
“Details”:”@{string(replace(variables(‘result’), ‘”‘,””))}”
}
AZURE LOGIC APP CONFIGURATION
- Copy json which was attached in web activities body, paste it into the “Request body JSON schema”
- Click Done
- The designer right window should look like the following:

- The next step is adding an action to the logic app workflow; before configuring the e-mail sending itself, customize a variable to hold the e-mail body message dynamically; Type “variable” in the search bar and select the Initialize variable operation.
- Enter values for Name and Type, then, add dynamic content and select the “Message” and other objects which are available since it’s passed in the HTTP request using the JSON:

- Hit Save and add a new step to the workflow:
- Then, from the list, choose the “Send an email v2” option
- In case you’re not connected to you e-mail provider account, you will prompt to do so. Otherwise, go on with the e-mail sending setup:

- Hit Save.
- The Logic App workflow is now configured!
Conclusion: Received HTML formatted email message
After passing the output of Lookup activity via ADF to Logic App, you will receive email message as expected: all lines formatted.

Geetha S