Email notifications are crucial to ensure the health of your Azure environment and processes. Azure supports email notifications to send alerts that monitor its resources and events. There are numerous methods in Azure to send email alerts. Below are a few common approaches:
- Azure Logic App
- Azure Automation Runbook
Azure Logic App
Azure Logic App is a cloud-based service which supports a feature to send email notifications through multiple services such as Outlook and Gmail.
A simple approach to send an outlook mail when a blob in the storage account is added or modified:
- Create a logic App resource within a resource group.
- Add a Trigger event as “When a blob is added or modified (properties only)” from Azure Blob Storage event
- Add an action “Send an email” from Office 365 Outlook event and create a connection with your outlook ID
- Specify the following Parameters:
- Required Parameters
- Required Parameters
- Optional Parameters
- From (Send As)
- Is HTML
- Dynamic Content can be provided to parameters based on the output of previous steps
Logic App Designer
Azure Automation Runbook
Azure Automation Runbook is a cloud-integrated user interface to develop PowerShell scripts. Using an SMTP configuration from a PowerShell script we can send email alerts to the users.
SMTP Configuration for outlook:
|SMTP server name||smtp-mail.outlook.com|
|SMTP encryption method||STARTTLS|
Email alerts when a pipeline run has failed with error details:
- Build an Azure automation runbook with SMTP Configuration for outlook server with the below script
- Configure a webhook for the runbook (Copy the webhook URL)
- In Azure Data Factory,
- Build a Pipeline with a required activity
- Handle Failure event with a web activity
- In settings configure the properties as shown below.
- In this demo, Pipeline name, Activity start time, Activity status, Error and Error description is captured. The recipient and subject are also passed through the pipeline. If there are multiple recipients, pass the values in parenthesis. For Reference,(‘XXX@XYZ.com’, ‘YYY@XYZ.com’)
Note: Failure Event is precise to a single activity. So, if there are 2 or more activities in your pipeline then for each activity, Failure events should be handled individually because Dependency between activities is Logical AND.
4. Whenever pipeline activity gets failed, ADF will invoke azure automation runbook through webhook and send error details.
- Create an automation account and build a PowerShell runbook with the below code.
- Update your Azure credentials in the automation account and pass the credential name in the code
5. Mail body can contain normal text or HTML content. Here the body is crafted with HTML along with a hyperlink
6. The following mail is produced by the above runbook whenever a pipeline activity fails
Learn more about Visual BI’s Microsoft Azure offerings here.