【问题标题】:Enabling an azure metric alert V2启用 Azure 指标警报 V2
【发布时间】:2021-04-16 15:53:30
【问题描述】:

我正在使用 azure 来监控 appservices,而在持续部署中,我正在尝试构建一个自动化任务以在部署期间禁用/启用警报

为了禁用警报它正在工作

Get-AzMetricAlertRuleV2 -ResourceGroupName "<resource group name>"  -Name "<alert name>" | Add-AzMetricAlertRuleV2 -DisableRule

用于在部署后启用警报

Get-AzMetricAlertRuleV2 -ResourceGroupName "<resource group name>"  -Name "<alert name>" | Add-AzMetricAlertRuleV2 -TargetResourceRegion "westeurope"

我收到以下错误:

Add-AzMetricAlertRuleV2: Exception type: ErrorResponseException, Message: Alert update failed. Updating from StaticThresholdCriteria and odata.type SingleResourceMultipleMetricCriteria to StaticThresholdCriteria and odata.type MultipleResourceMultipleMetricCriteria is not supported. Activity ID: ec818831-0516-44a7-92ff-cbddaa82b634., Code: BadRequest, Status code:BadRequest, Reason phrase: BadRequest

【问题讨论】:

    标签: azure powershell azure-devops monitor azure-alerts


    【解决方案1】:

    您不应在启用时通过传递-TargetResourceRegion 参数来更改区域。 Add-AzMetricAlertRuleV2 正在尝试添加一个新规则,认为它是一个新规则并且由于显示的错误消息 (Updating from StaticThresholdCriteria and odata.type SingleResourceMultipleMetricCriteria to StaticThresholdCriteria and odata.type MultipleResourceMultipleMetricCriteria is not supported) 而失败。因此,只需在不传递任何其他参数(如下所示)的情况下启用即可。

    Get-AzMetricAlertRuleV2 -ResourceGroupName "<resource group name>"  -Name "<alert name>" | Add-AzMetricAlertRuleV2
    
    

    【讨论】:

      猜你喜欢
      • 2021-11-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-10-05
      • 2018-08-20
      • 1970-01-01
      • 1970-01-01
      • 2019-12-26
      相关资源
      最近更新 更多