-1

我正在使用 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
4

1 回答 1

0

启用时不应通过传递-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-01-11T19:02:56.697 回答