We are working heavily with Azure Automation for our customers and often need a simple Alert for errors happening in a runbook. Of course, there are plenty of Alerting Solutions where you can integrate Azure Automation.
We often see that things don’t go well or that the Alerts are not monitored. When we do Azure Automation Consulting, we also take care of Alerts, so we use simple Mail Alerting in Azure.
Here I want to show how we are configuring this at our Customers.
Open portal.azure.com with appropriate Permissions to create an Alert Rule and create a Diagnostic Setting
Open your Azure Automation Account
Navigate to Monitoring/Diagnostic settings
and click “Add diagnostic setting.”
select “allLogs” and “AllMetrics”
Select “Send to Log Analytics workspace” and select or create a Log Analytics workspace.
Click “Save.”
Navigate to Monitoring/Alerts in the same Automation Account
Create a new “Alert Rule.”
On the “Condition” Tab, choose “Custom Log Search” from Signal name
Enter the following Query in the “Search Query”
// Find logs reporting errors in automation jobs from the last day
// List all the errors in the automation jobs.
// To create an alert for this query, click '+ New alert rule'
AzureDiagnostics
| where ResourceProvider == "MICROSOFT.AUTOMATION"
| where StreamType_s == "Error"
| project TimeGenerated, Category, JobId_g, OperationName, RunbookName_s, ResultDescription, _ResourceId
Choose the following Option at Measurement and Alert Logic
At the “Actions” Tab, choose “Use quick actions” and configure your Mail Alert
At the “Details” Page, choose your preferred Alert Details
I would recommend choosing “1- Error” for Severity; the rest is up to you and your Environment
So, whenever an error happens in one of your Runbooks, you should receive an email
The Scenario
So, when you have a Runbook that shows the State “Completed” but throws an error inside with “Write-Error,” you usually will not be notified. It will not show up on the Main Logs Page.
So, with our solution, you will receive an Email like this
By the click on “View query results,” you will see the triggered runbook that caused the Error
So, no more excuses that Alerting it to complicates.
The cost of this will be around 1,50 Euro per Month.
Michael Seidl aka Techguy
#autoamtionmindset
Hi Michael,
Great article!
In the past, I have followed many of your articles they are very clear and well explained. I’m currently looking for an automation solution that allows checking Power Automate flows for failed jobs on an hourly basis. Have you written an article on this topic as well? Best regards Stefan
Hi, sorry, no i haven’t done that yet.