我正在尝试使用带有几个属性的 azure CLI 批量更新一堆警报。 我可以使用此命令更新操作组:
az resource update --name AlertName --resource-group MyResourceGroup --resource-type microsoft.insights/metricAlerts --add properties.actions "actionGroupId=/subscriptions/9999/resourcegroups/MyResourceGroup /providers/microsoft.insights/actiongroups/MyActionGroup"
我还想在操作中添加 webHookProperties,但我似乎无法获得正确的语法。我收到如下错误:
az : ERROR: (BadRequest) Error converting value "{'test'='data'}, actionGroupId=/subscriptions/asd/resourcegroups/MyResourceGroup /providers/microsoft.insights/actiongroups/MyActionGroup" to type
'System.Collections.Generic.IDictionary`2[System.String,System.String]'. Path '[1].webHookProperties'
如何传入命令所需的字典? 谢谢!
如何使用 azure CLI 添加操作属性以发出警报
要在警报中正确更新
webHookProperties
,您需要适当地设置 properties.actions
参数的格式。
这里是 updated 命令,用于添加 action properties 以使用
azure CLI
进行警报。
az resource update --name "Venkat-alert" --resource-group "Venkat" --resource-type microsoft.insights/metricAlerts --set properties.actions='[{"actionGroupId":"/subscriptions/158b8345-c359-4d98-95c5-f21815dd048f/resourceGroups/Venkat/providers/microsoft.insights/actiongroups/Application Insights Smart Detection", "webHookProperties":{"test":"data"}}]'
输出:
运行上述命令后,
Action Group ID
和webHookProperties都会使用az resource update
进行更新。