【发布时间】:2019-06-24 06:09:57
【问题描述】:
在 Azure 中,当您设置了带有故障转移组的 SQL Server 并且故障转移策略设置为自动时,如何在发生 SQL Server 故障转移时配置警报或电子邮件通知?
那么,谁能建议我如何为上述场景配置警报?
【问题讨论】:
标签: azure azure-sql-database azure-sql-server azure-monitoring sql-azure-alerts
在 Azure 中,当您设置了带有故障转移组的 SQL Server 并且故障转移策略设置为自动时,如何在发生 SQL Server 故障转移时配置警报或电子邮件通知?
那么,谁能建议我如何为上述场景配置警报?
【问题讨论】:
标签: azure azure-sql-database azure-sql-server azure-monitoring sql-azure-alerts
您参考了这个博客:In Azure, how can you configure an alert or notification when a SQL Server failover happened?
CKelly 找到了一种在 Azure 中使用自动化帐户 > Runbook > 使用 Powershell 编写脚本的方法。像这样的简单脚本应该可以做到。只需要弄清楚 run as account 并通过 schedule 或 alert 触发它。:
function sendEmailAlert
{
# Send email
}
function checkFailover
{
$list = Get-AzSqlDatabaseFailoverGroup -ResourceGroupName "my-resourceGroup" -server "my-sql-server"
if ( $list.ReplicationRole -ne 'Primary')
{
sendEmailAlert
}
}
checkFailover
希望这会有所帮助。
【讨论】: