使用 azure cli 自动为资源创建诊断设置

时间:2021-05-26 16:05:01

标签: azure azure-cli

方法:

az monitor diagnostic-settings create --resource $resourceId -n $name --event-hub $eventHub --logs '[ { "category": "WorkflowRuntime", "enabled": true, "retentionPolicy": { "enabled": false, "days": 0 } } ]' --metrics '[ { "category": "WorkflowRuntime", "enabled": true, "retentionPolicy": { "enabled": false, "days": 0 } } ]

期待

为由 resourceId 标识的指定资源创建诊断设置

实际

(BadRequest) Metric category 'WorkflowRuntime' is not supported, supported categories are: 'Capacity;Transaction'.

对这个问题的任何帮助都会很棒。谢谢。

1 个答案:

答案 0 :(得分:0)

根据错误,该资源没有日志类别。事实上,不同的资源类型有不同的日志类别。详情请参阅hereenter image description here

如果你想获取一种资源的可用类别,可以使用以下命令

az monitor diagnostic-settings categories list --resource <resource id>