Hi All,
We've a requirement to create a Service Principle which can,
- read all resource details (including which all resources are available)
- have deploy / write access only for all types of Alerts (Metrics, Scheduled query, Azure managed Prometheus etc.) and Action Groups
The Alert / Action groups are required to be created via ARM template or Terraform to store Monitoring as Code to maintain version control of monitoring requirements.
I have been trying to work this out, found two existing roles,
- Read
- Monitoring Contributor
But the 2nd one has limited to use Azure Monitor CLI and doesn't allow ARM template deployment. Hence below two access will have to be added:
"Microsoft.Resources/deployments/write",
"Microsoft.Resources/deployments/read"
But adding these will mean giving access to deploying any resource using ARM. To restrict that, we can add below in NotActions:
"Microsoft.Compute/",
"Microsoft.Storage/",
"Microsoft.Network/*",
"Microsoft.Resources/deployments/validate",
"Microsoft.Resources/deployments/cancel"
Final json would look like below, due to Org level restrictions it is difficult to create this role and test it. Hence looking forward an expert opinion from community, if it looks good and if there are any other suggestions.
Thank you for your help in advance.
{
"Name": "custom-Monitoring-Contributor",
"IsCustom": true,
"Description": "Allows deployment of ARM templates for alerts and action groups only, with full monitoring read permissions.",
"Actions": [
"Microsoft.Resources/deployments/write",
"Microsoft.Resources/deployments/read",
"Microsoft.Insights/metricAlerts/*",
"Microsoft.Insights/scheduledQueryRules/*",
"Microsoft.AlertsManagement/smartDetectorAlertRules/*",
"Microsoft.Monitor/accounts/*",
"Microsoft.Insights/actionGroups/*",
"Microsoft.Insights/*",
"Microsoft.Monitor/*",
"Microsoft.AlertsManagement/*",
"Microsoft.OperationalInsights/*",
"*"
],
"AssignableScopes": [
"/subscriptions/{subscription-id}"
],
"DataActions": [],
"NotActions": [
"Microsoft.Compute/*",
"Microsoft.Storage/*",
"Microsoft.Network/*",
"Microsoft.Resources/deployments/validate",
"Microsoft.Resources/deployments/cancel"
]
}