Azure Replication Status Report – Email Notification

Recently I was given the task to monitor the replication status of a large number of servers, I really didn’t want to be going via the classic console and clicking inside every replication group just to make sure things were rolling smoothly. It got me thinking about how I could automate this task using Azure Automation Run books.

I started digging around and came across a post where a gentleman had written a Powershell script to deliver the daily backup jobs via email. It was not exactly what I wanted so I took that script and modified it to deliver the information I required.

First step is to create a runbook in Azure

Give the runbook a useful name and choose the powershell option as the runbook type

For the runbook to create a connection you will need to add the following code at the start of your script, if you have not setup an Azure RunasAccount you can follow these instructions – Authenticate runbooks with an Azure Run As account

Be sure to populate your runas account next to $connectionName

Next Add the code below

This is the workhorse that produces the report, you will need to populate your SMTP settings

You are now ready to test the runbook works

Select Test pane

Select edit and start the test, the runbook will be queue for an automation worker to pick it up


Wait for the runbook to complete.

A new email should arrive with a table of results like below

Now you just need to publish the runbook and add a schedule

You can set the schedule for an hourly drop into your inbox or drop the results into a group inbox.

Leave a Reply