簡體   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