繁体   English   中英

针对Azure中VM的自定义指标

[英]Custom Metrics against a VM in Azure

我在“ Microsoft.Insights / Metrics / write”上收到授权错误

我有一个虚拟机资源和一个具有贡献者角色的服务原则。 我正在尝试针对虚拟机资源发出指标。 请按照此处的指南进行操作: https : //docs.microsoft.com/zh-cn/azure/azure-monitor/platform/metrics-store-custom-rest-api

但我收到此错误:

{“错误”:{“代码”:“ AuthenticationFailed”,“消息”:“ Azure AD对象'0f6a81eb-8950-43eb-989a-f715fb84e4e2'没有执行操作'Microsoft.Insights / Metrics / write'的权限超出范围'/subscriptions/ba0583bb-4130-4d7b-bfe4-0c7597857323/resourceGroups/sample-PM-LA-resourceGrp/providers/Microsoft.Compute/virtualMachines/sample-PM-virtualMachine'。“}}

这是我在做什么:

curl -X POST https://westus2.monitoring.azure.com/subscriptions/ba0583bb-4130-4d7b-bfe4-0c7597857323/resourceGroups/sample-PM-LA-resourceGrp/providers/Microsoft.Compute/virtualMachines/sample-PM-virtualMachine/metrics -H "Content-Type: application/json" -H "Authorization: Bearer <auth-code>" -d @custommetric.json

和我得到的错误:

{"error":{"code":"AuthenticationFailed","message":"The Azure AD object '0f6a81eb-8950-43eb-989a-f715fb84e4e2' does not have permissions to perform action 'Microsoft.Insights/Metrics/write' over scope '/subscriptions/ba0583bb-4130-4d7b-bfe4-0c7597857323/resourceGroups/sample-PM-LA-resourceGrp/providers/Microsoft.Compute/virtualMachines/sample-PM-virtualMachine'. "}}

有谁知道为什么会这样吗? 我具有必需的权限,并且服务原则也已获得权限。

我看到您提到创建的服务主体具有Contributor角色。

Microsoft文档专门要求服务主体具有Monitoring Metrics Publisher角色。

在此处输入图片说明

另外,我看到这个GitHub线程与您的问题非常相似,即使资源的Owner角色也没有此特定权限,因此它可能不是很直观。

因此,请尝试为Service Principal添加Monitoring Metrics Publisher角色

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM