如何修改 Azure 監視器的存取權限
根據預設,建立 Grafana 實例時,它會在訂用帳戶內的所有 Azure 監視器資料和 Log Analytics 資源上授與監視讀取者角色。
這表示新的 Grafana 實例可以存取和搜尋訂用帳戶中的所有監視資料。 它可以檢視來自所有資源的 Azure 監視器計量和記錄,以及訂用帳戶中 Log Analytics 工作區中儲存的任何記錄。
在本文中,瞭解如何使用受控識別手動授與 Azure 受控 Grafana 的許可權,以存取 Azure 資源。
必要條件
- 具有有效訂用帳戶的 Azure 帳戶。 免費建立帳戶。
- Azure 受控 Grafana 實例。 如果您還沒有 Azure 受控 Grafana 實例 , 請建立。
- 具有監視資料和寫入權限的 Azure 資源,例如 使用者存取管理員istrator 或 擁有者
登入 Azure
請使用您的 Azure 帳戶登入 Azure 入口網站 (https://portal.azure.com/)。
編輯 Azure 監視器許可權
若要編輯特定資源的許可權,請遵循下列步驟。
開啟包含您要擷取之監視資料的資源。 在此範例中,我們會設定 Application Insights 資源。
選取存取控制 (IAM)。
在授與此資源的存取權下方,選取新增角色指派。
入口網站會列出您可以提供給 Azure 受控 Grafana 資源的所有角色。 選取角色。 例如, 監視讀取器 ,然後選取 [ 下一步 ]。
針對 [ 指派存取權] ,選取 [ 受控識別 ]。
按一下 [ 選取成員 ]。
選取包含受控 Grafana 實例的訂 用帳戶。
針對 [受控識別 ],選取 [Azure 受控 Grafana ]。
選取一或多個受控 Grafana 實例。
按一下 [ 選取 ] 以確認
選取 [下一步 ],然後 選取 [檢閱 + 指派 ] 以確認新許可權的指派。
如需如何使用受控 Grafana 搭配 Azure 監視器的詳細資訊,請移至 在 Grafana 中監視您的 Azure 服務。
使用 az role assignment create 命令指派角色指派。
在下列程式碼中,取代下列預留位置:
<assignee>
:如果其 --assignee 參數,請輸入被指派者的物件識別碼或使用者登入名稱或服務主體名稱。 如果其 --assignee-object-id 參數,請輸入使用者或群組或服務主體或受控識別的物件識別碼。 針對受控識別,請使用主體識別碼。 針對服務主體,請使用物件識別碼,而不是應用程式識別碼。 如需詳細資訊,請參閱 az role assignment create 命令。
<roleNameOrId>
:輸入角色的名稱或識別碼。 針對 [監視讀取器],輸入 Monitoring Reader
或 43d0d8ad-25c7-4714-9337-8ba259a9fe05
。
<scope>
:輸入 Azure 受控 Grafana 需要存取之資源的完整識別碼。
az role assignment create --assignee "<assignee>" \
--role "<roleNameOrId>" \
--scope "<scope>"
或
az role assignment create --assignee-object-id "<assignee>" --assignee-principal-type "<ForeignGroup / Group / ServicePrincipal / User>" \
--role "<roleNameOrId>" \
--scope "<scope>"
範例:指派 Azure 受控 Grafana 實例的許可權,以使用受控識別存取 Application Insights 資源。
az role assignment create --assignee-object-id "abcdef01-2345-6789-0abc-def012345678" --assignee-principal-type "ServicePrincipal" \
--role "Monitoring Reader" \
--scope "/subscriptions/abcdef01-2345-6789-0abc-def012345678/resourcegroups/my-rg/providers/microsoft.insights/components/myappinsights/"
如需使用 Azure CLI 指派 Azure 角色的詳細資訊,請參閱 角色型存取控制檔 。
下一步