Gallery › Monitoring › Azure built-in policies
Azure Monitor should collect activity logs from all regions
Uses Condition Policy AuditIfNotExists Disabled Mode All Version 2.0.0
This policy audits the Azure Monitor log profile which does not export activities from all Azure supported regions including global.
ConvertTo-Bylaw converted this policy, and proved it compiles back to the same definition. Conditions the language can't express yet are written as raw JSON with Condition.
Azure Policy JSONActivityLog_CaptureAllRegions.json · 312 lines
{
"properties": {
"displayName": "Azure Monitor should collect activity logs from all regions",
"policyType": "BuiltIn",
"mode": "All",
"description": "This policy audits the Azure Monitor log profile which does not export activities from all Azure supported regions including global.",
"metadata": {
"version": "2.0.0",
"category": "Monitoring"
},
"version": "2.0.0",
"parameters": {
"effect": {
"type": "string",
"defaultValue": "AuditIfNotExists",
"allowedValues": [
"AuditIfNotExists",
"Disabled"
],
"metadata": {
"displayName": "Effect",
"description": "Enable or disable the execution of the policy"
}
}
},
"policyRule": {
"if": {
"field": "type",
"equals": "Microsoft.Resources/subscriptions"
},
"then": {
"effect": "[parameters('effect')]",
"details": {
"type": "Microsoft.Insights/logProfiles",
"existenceCondition": {
"allOf": [
{
"not": {
"field": "Microsoft.Insights/logProfiles/locations[*]",
"notEquals": "australiacentral"
}
},
{
"not": {
"field": "Microsoft.Insights/logProfiles/locations[*]",
"notEquals": "australiacentral2"
}
},
{
"not": {
"field": "Microsoft.Insights/logProfiles/locations[*]",
"notEquals": "australiaeast"
}
},
{
"not": {
"field": "Microsoft.Insights/logProfiles/locations[*]",
"notEquals": "australiasoutheast"
}
},
{
"not": {
"field": "Microsoft.Insights/logProfiles/locations[*]",
"notEquals": "brazilsouth"
}
},
{
"not": {
"field": "Microsoft.Insights/logProfiles/locations[*]",
"notEquals": "brazilsoutheast"
}
},
{
"not": {
"field": "Microsoft.Insights/logProfiles/locations[*]",
"notEquals": "canadacentral"
}
},
{
"not": {
"field": "Microsoft.Insights/logProfiles/locations[*]",
"notEquals": "canadaeast"
}
},
{
"not": {
"field": "Microsoft.Insights/logProfiles/locations[*]",
"notEquals": "centralindia"
}
},
{
"not": {
"field": "Microsoft.Insights/logProfiles/locations[*]",
"notEquals": "centralus"
}
},
{
"not": {
"field": "Microsoft.Insights/logProfiles/locations[*]",
"notEquals": "eastasia"
}
},
{
"not": {
"field": "Microsoft.Insights/logProfiles/locations[*]",
"notEquals": "eastus"
}
},
{
"not": {
"field": "Microsoft.Insights/logProfiles/locations[*]",
"notEquals": "eastus2"
}
},
{
"not": {
"field": "Microsoft.Insights/logProfiles/locations[*]",
"notEquals": "francecentral"
}
},
{
"not": {
"field": "Microsoft.Insights/logProfiles/locations[*]",
"notEquals": "francesouth"
}
},
{
"not": {
"field": "Microsoft.Insights/logProfiles/locations[*]",
"notEquals": "germanynorth"
}
},
{
"not": {
"field": "Microsoft.Insights/logProfiles/locations[*]",
"notEquals": "germanywestcentral"
}
},
{
"not": {
"field": "Microsoft.Insights/logProfiles/locations[*]",
"notEquals": "japaneast"
}
},
{
"not": {
"field": "Microsoft.Insights/logProfiles/locations[*]",
"notEquals": "japanwest"
}
},
{
"not": {
"field": "Microsoft.Insights/logProfiles/locations[*]",
"notEquals": "jioindiawest"
}
},
{
"not": {
"field": "Microsoft.Insights/logProfiles/locations[*]",
"notEquals": "koreacentral"
}
},
{
"not": {
"field": "Microsoft.Insights/logProfiles/locations[*]",
"notEquals": "koreasouth"
}
},
{
"not": {
"field": "Microsoft.Insights/logProfiles/locations[*]",
"notEquals": "northcentralus"
}
},
{
"not": {
"field": "Microsoft.Insights/logProfiles/locations[*]",
"notEquals": "northeurope"
}
},
{
"not": {
"field": "Microsoft.Insights/logProfiles/locations[*]",
"notEquals": "norwayeast"
}
},
{
"not": {
"field": "Microsoft.Insights/logProfiles/locations[*]",
"notEquals": "norwaywest"
}
},
{
"not": {
"field": "Microsoft.Insights/logProfiles/locations[*]",
"notEquals": "southafricanorth"
}
},
{
"not": {
"field": "Microsoft.Insights/logProfiles/locations[*]",
"notEquals": "southafricawest"
}
},
{
"not": {
"field": "Microsoft.Insights/logProfiles/locations[*]",
"notEquals": "southcentralus"
}
},
{
"not": {
"field": "Microsoft.Insights/logProfiles/locations[*]",
"notEquals": "southeastasia"
}
},
{
"not": {
"field": "Microsoft.Insights/logProfiles/locations[*]",
"notEquals": "southindia"
}
},
{
"not": {
"field": "Microsoft.Insights/logProfiles/locations[*]",
"notEquals": "switzerlandnorth"
}
},
{
"not": {
"field": "Microsoft.Insights/logProfiles/locations[*]",
"notEquals": "switzerlandwest"
}
},
{
"not": {
"field": "Microsoft.Insights/logProfiles/locations[*]",
"notEquals": "uaecentral"
}
},
{
"not": {
"field": "Microsoft.Insights/logProfiles/locations[*]",
"notEquals": "uaenorth"
}
},
{
"not": {
"field": "Microsoft.Insights/logProfiles/locations[*]",
"notEquals": "uksouth"
}
},
{
"not": {
"field": "Microsoft.Insights/logProfiles/locations[*]",
"notEquals": "ukwest"
}
},
{
"not": {
"field": "Microsoft.Insights/logProfiles/locations[*]",
"notEquals": "westcentralus"
}
},
{
"not": {
"field": "Microsoft.Insights/logProfiles/locations[*]",
"notEquals": "westeurope"
}
},
{
"not": {
"field": "Microsoft.Insights/logProfiles/locations[*]",
"notEquals": "westindia"
}
},
{
"not": {
"field": "Microsoft.Insights/logProfiles/locations[*]",
"notEquals": "westus"
}
},
{
"not": {
"field": "Microsoft.Insights/logProfiles/locations[*]",
"notEquals": "westus2"
}
},
{
"not": {
"field": "Microsoft.Insights/logProfiles/locations[*]",
"notEquals": "westus3"
}
},
{
"not": {
"field": "Microsoft.Insights/logProfiles/locations[*]",
"notEquals": "global"
}
}
]
}
}
}
},
"versions": [
"2.0.0"
]
},
"id": "/providers/Microsoft.Authorization/policyDefinitions/41388f1c-2db0-4c25-95b2-35d7f5ccbfa9",
"name": "41388f1c-2db0-4c25-95b2-35d7f5ccbfa9"
}Bylaw41388f1c-2db0-4c25-95b2-35d7f5ccbfa9.bylaw.ps1 · 71 lines
# Converted from ActivityLog_CaptureAllRegions.json by ConvertTo-Bylaw.
Policy '41388f1c-2db0-4c25-95b2-35d7f5ccbfa9' {
Properties @{
DisplayName = 'Azure Monitor should collect activity logs from all regions'
Description = 'This policy audits the Azure Monitor log profile which does not export activities from all Azure supported regions including global.'
Version = '2.0.0'
Category = 'Monitoring'
PolicyVersion = '2.0.0'
Mode = 'All'
}
Parameter Effect @{
Type = 'string'
AllowedValues = @('AuditIfNotExists', 'Disabled')
Default = 'AuditIfNotExists'
DisplayName = 'Effect'
Description = 'Enable or disable the execution of the policy'
}
Resource 'Microsoft.Resources/subscriptions'
AuditIfNotExists 'Microsoft.Insights/logProfiles' -Effect (Param Effect) {
Require 'locations is as required' {
Condition -Compliant '{ "not": { "field": "Microsoft.Insights/logProfiles/locations[*]", "notEquals": "australiacentral" } }'
Condition -Compliant '{ "not": { "field": "Microsoft.Insights/logProfiles/locations[*]", "notEquals": "australiacentral2" } }'
Condition -Compliant '{ "not": { "field": "Microsoft.Insights/logProfiles/locations[*]", "notEquals": "australiaeast" } }'
Condition -Compliant '{ "not": { "field": "Microsoft.Insights/logProfiles/locations[*]", "notEquals": "australiasoutheast" } }'
Condition -Compliant '{ "not": { "field": "Microsoft.Insights/logProfiles/locations[*]", "notEquals": "brazilsouth" } }'
Condition -Compliant '{ "not": { "field": "Microsoft.Insights/logProfiles/locations[*]", "notEquals": "brazilsoutheast" } }'
Condition -Compliant '{ "not": { "field": "Microsoft.Insights/logProfiles/locations[*]", "notEquals": "canadacentral" } }'
Condition -Compliant '{ "not": { "field": "Microsoft.Insights/logProfiles/locations[*]", "notEquals": "canadaeast" } }'
Condition -Compliant '{ "not": { "field": "Microsoft.Insights/logProfiles/locations[*]", "notEquals": "centralindia" } }'
Condition -Compliant '{ "not": { "field": "Microsoft.Insights/logProfiles/locations[*]", "notEquals": "centralus" } }'
Condition -Compliant '{ "not": { "field": "Microsoft.Insights/logProfiles/locations[*]", "notEquals": "eastasia" } }'
Condition -Compliant '{ "not": { "field": "Microsoft.Insights/logProfiles/locations[*]", "notEquals": "eastus" } }'
Condition -Compliant '{ "not": { "field": "Microsoft.Insights/logProfiles/locations[*]", "notEquals": "eastus2" } }'
Condition -Compliant '{ "not": { "field": "Microsoft.Insights/logProfiles/locations[*]", "notEquals": "francecentral" } }'
Condition -Compliant '{ "not": { "field": "Microsoft.Insights/logProfiles/locations[*]", "notEquals": "francesouth" } }'
Condition -Compliant '{ "not": { "field": "Microsoft.Insights/logProfiles/locations[*]", "notEquals": "germanynorth" } }'
Condition -Compliant '{ "not": { "field": "Microsoft.Insights/logProfiles/locations[*]", "notEquals": "germanywestcentral" } }'
Condition -Compliant '{ "not": { "field": "Microsoft.Insights/logProfiles/locations[*]", "notEquals": "japaneast" } }'
Condition -Compliant '{ "not": { "field": "Microsoft.Insights/logProfiles/locations[*]", "notEquals": "japanwest" } }'
Condition -Compliant '{ "not": { "field": "Microsoft.Insights/logProfiles/locations[*]", "notEquals": "jioindiawest" } }'
Condition -Compliant '{ "not": { "field": "Microsoft.Insights/logProfiles/locations[*]", "notEquals": "koreacentral" } }'
Condition -Compliant '{ "not": { "field": "Microsoft.Insights/logProfiles/locations[*]", "notEquals": "koreasouth" } }'
Condition -Compliant '{ "not": { "field": "Microsoft.Insights/logProfiles/locations[*]", "notEquals": "northcentralus" } }'
Condition -Compliant '{ "not": { "field": "Microsoft.Insights/logProfiles/locations[*]", "notEquals": "northeurope" } }'
Condition -Compliant '{ "not": { "field": "Microsoft.Insights/logProfiles/locations[*]", "notEquals": "norwayeast" } }'
Condition -Compliant '{ "not": { "field": "Microsoft.Insights/logProfiles/locations[*]", "notEquals": "norwaywest" } }'
Condition -Compliant '{ "not": { "field": "Microsoft.Insights/logProfiles/locations[*]", "notEquals": "southafricanorth" } }'
Condition -Compliant '{ "not": { "field": "Microsoft.Insights/logProfiles/locations[*]", "notEquals": "southafricawest" } }'
Condition -Compliant '{ "not": { "field": "Microsoft.Insights/logProfiles/locations[*]", "notEquals": "southcentralus" } }'
Condition -Compliant '{ "not": { "field": "Microsoft.Insights/logProfiles/locations[*]", "notEquals": "southeastasia" } }'
Condition -Compliant '{ "not": { "field": "Microsoft.Insights/logProfiles/locations[*]", "notEquals": "southindia" } }'
Condition -Compliant '{ "not": { "field": "Microsoft.Insights/logProfiles/locations[*]", "notEquals": "switzerlandnorth" } }'
Condition -Compliant '{ "not": { "field": "Microsoft.Insights/logProfiles/locations[*]", "notEquals": "switzerlandwest" } }'
Condition -Compliant '{ "not": { "field": "Microsoft.Insights/logProfiles/locations[*]", "notEquals": "uaecentral" } }'
Condition -Compliant '{ "not": { "field": "Microsoft.Insights/logProfiles/locations[*]", "notEquals": "uaenorth" } }'
Condition -Compliant '{ "not": { "field": "Microsoft.Insights/logProfiles/locations[*]", "notEquals": "uksouth" } }'
Condition -Compliant '{ "not": { "field": "Microsoft.Insights/logProfiles/locations[*]", "notEquals": "ukwest" } }'
Condition -Compliant '{ "not": { "field": "Microsoft.Insights/logProfiles/locations[*]", "notEquals": "westcentralus" } }'
Condition -Compliant '{ "not": { "field": "Microsoft.Insights/logProfiles/locations[*]", "notEquals": "westeurope" } }'
Condition -Compliant '{ "not": { "field": "Microsoft.Insights/logProfiles/locations[*]", "notEquals": "westindia" } }'
Condition -Compliant '{ "not": { "field": "Microsoft.Insights/logProfiles/locations[*]", "notEquals": "westus" } }'
Condition -Compliant '{ "not": { "field": "Microsoft.Insights/logProfiles/locations[*]", "notEquals": "westus2" } }'
Condition -Compliant '{ "not": { "field": "Microsoft.Insights/logProfiles/locations[*]", "notEquals": "westus3" } }'
Condition -Compliant '{ "not": { "field": "Microsoft.Insights/logProfiles/locations[*]", "notEquals": "global" } }'
}
}
}Source: built-in-policies/policyDefinitions/Monitoring/ActivityLog_CaptureAllRegions.json in Azure/azure-policy, under the MIT licence.
Bylaw