如何修复使用Azure CLI创建Application Insight警报时的‘Scope can not be updated’错误
解决Azure中使用
az monitor scheduled-query创建Application Insight警报时的"Scope can not be updated"错误 确认操作类型:如果是新建警报,必须使用
create子命令,不要误用update。错误常出现在误将新建操作写成更新,导致尝试修改不允许变更的scope参数。正确创建命令示例:az monitor scheduled-query create --name "你的警报名称" --resource-group "资源组名称" --scopes "/subscriptions/订阅ID/resourceGroups/资源组名称/providers/microsoft.insights/components/你的ApplicationInsights名称" --condition "count requests where success == false > 5" --description "请求失败警报" --severity 2若为更新现有警报,禁止修改scope参数:Azure计划查询警报创建后,关联的资源范围(scope)不支持变更。更新命令中需移除
--scopes参数,仅修改允许变更的内容(如警报条件、描述等)。正确更新命令示例:az monitor scheduled-query update --name "你的警报名称" --resource-group "资源组名称" --condition "count requests where success == false > 10"校验scope参数格式:确保使用的是正确的Application Insights组件资源ID,可通过以下命令获取准确ID:
az resource show --resource-group "资源组名称" --name "你的ApplicationInsights名称" --resource-type "microsoft.insights/components" --query id --output tsv直接复制输出结果作为
--scopes参数值,避免手动输入错误。检查账户权限:执行命令的账户需拥有Monitoring Contributor或Owner权限,权限不足可能触发类似请求错误。
内容的提问来源于stack exchange,提问作者Hoaitri Ho
相关产品推荐
相关产品推荐

