Gallery › Managed Grafana › Azure built-in policies
Configure Azure Managed Grafana workspaces to disable service account
Converted Policy Disabled Modify Mode Indexed Version 1.0.0
Disable API keys and service account for automated workloads in Grafana workspace.
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONAMG_ServiceAccount_Modify.json · 63 lines
{
"properties": {
"displayName": "Configure Azure Managed Grafana workspaces to disable service account",
"policyType": "BuiltIn",
"mode": "Indexed",
"description": "Disable API keys and service account for automated workloads in Grafana workspace.",
"metadata": {
"version": "1.0.0",
"category": "Managed Grafana"
},
"version": "1.0.0",
"parameters": {
"effect": {
"type": "String",
"metadata": {
"displayName": "Effect",
"description": "Enable or disable the execution of the policy"
},
"allowedValues": [
"Modify",
"Disabled"
],
"defaultValue": "Modify"
}
},
"policyRule": {
"if": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.Dashboard/grafana"
},
{
"field": "Microsoft.Dashboard/grafana/apiKey",
"equals": "Enabled"
}
]
},
"then": {
"effect": "[parameters('effect')]",
"details": {
"conflictEffect": "audit",
"roleDefinitionIds": [
"/providers/microsoft.authorization/roleDefinitions/b24988ac-6180-42a0-ab88-20f7382dd24c"
],
"operations": [
{
"condition": "[greaterOrEquals(requestContext().apiVersion, '2022-10-01-preview')]",
"operation": "addOrReplace",
"field": "Microsoft.Dashboard/grafana/apiKey",
"value": "Disabled"
}
]
}
}
},
"versions": [
"1.0.0"
]
},
"id": "/providers/Microsoft.Authorization/policyDefinitions/cc4dfa24-c7df-47e4-80ff-3728adb3f9a0",
"name": "cc4dfa24-c7df-47e4-80ff-3728adb3f9a0"
}Bylawcc4dfa24-c7df-47e4-80ff-3728adb3f9a0.bylaw.ps1 · 30 lines
# Converted from AMG_ServiceAccount_Modify.json by ConvertTo-Bylaw.
Policy 'cc4dfa24-c7df-47e4-80ff-3728adb3f9a0' {
Properties @{
DisplayName = 'Configure Azure Managed Grafana workspaces to disable service account'
Description = 'Disable API keys and service account for automated workloads in Grafana workspace.'
Version = '1.0.0'
Category = 'Managed Grafana'
PolicyVersion = '1.0.0'
Mode = 'Indexed'
}
Parameter Effect @{
AllowedValues = @('Modify', 'Disabled')
Default = 'Modify'
DisplayName = 'Effect'
Description = 'Enable or disable the execution of the policy'
}
Resource 'Microsoft.Dashboard/grafana' {
Require 'apiKey is not Enabled' {
Field apiKey | Must -Not -Be 'Enabled' -IfPresent
}
}
Modify -Role 'Contributor' -ConflictEffect Audit -Effect (Param Effect) {
Field apiKey | AddOrReplace 'Disabled' -Condition (Arm '[greaterOrEquals(requestContext().apiVersion, ''2022-10-01-preview'')]')
}
}Source: built-in-policies/policyDefinitions/Managed Grafana/AMG_ServiceAccount_Modify.json in Azure/azure-policy, under the MIT licence.
Bylaw