如何在主 Azure SQL 数据库出现故障时配置警报?

How to configure the alert whenever the primary Azure SQL Database goes down?

在 Azure 中,如果设置了具有故障转移组的 SQL 服务器并且故障转移策略设置为自动,那么当发生 SQL 服务器故障转移时,如何配置警报或电子邮件通知?

那么,有人可以建议我如何为上述情况配置警报吗?

您引用此博客:

CKelly 找到了一种在 Azure 中使用自动化帐户 > Runbook > 使用 Powershell 编写脚本的方法。像这样的简单脚本应该可以做到。只需要找出 运行 作为帐户并按计划或警报触发它。:

function sendEmailAlert
{
    # Send email
}


function checkFailover
{
    $list = Get-AzSqlDatabaseFailoverGroup -ResourceGroupName "my-resourceGroup" -server "my-sql-server"

    if ( $list.ReplicationRole -ne 'Primary')
    { 
        sendEmailAlert
    }
}

checkFailover

希望对您有所帮助。