In Azure, how can you configure an alert or email notification when a SQL Server failover happened whenever you have setup a SQL server with Failover groups and failover policy is set to automatic?
So, can anyone suggest me how to configure the alert for the above scenario?
You reference this blog: In Azure, how can you configure an alert or notification when a SQL Server failover happened?
CKelly found a way to script this in Azure using Automation Accounts > Runbook > using Powershell. A simple script like this should do it. Just need to figure out the run as account and trigger it by schedule or alert.:
function sendEmailAlert
{
# Send email
}
function checkFailover
{
$list = Get-AzSqlDatabaseFailoverGroup -ResourceGroupName "my-resourceGroup" -server "my-sql-server"
if ( $list.ReplicationRole -ne 'Primary')
{
sendEmailAlert
}
}
checkFailover
Hope this helps.