Gallery › General › Azure built-in policies
Allowed locations for resource groups
Converted Policy Audit Deny Disabled Mode All Version 1.1.0
This policy enables you to restrict the locations your organization can create resource groups in. Use to enforce your geo-compliance requirements.
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONResourceGroupAllowedLocations_Deny.json · 59 lines
{
"properties": {
"displayName": "Allowed locations for resource groups",
"policyType": "BuiltIn",
"mode": "All",
"description": "This policy enables you to restrict the locations your organization can create resource groups in. Use to enforce your geo-compliance requirements.",
"metadata": {
"version": "1.1.0",
"category": "General"
},
"version": "1.1.0",
"parameters": {
"listOfAllowedLocations": {
"type": "Array",
"metadata": {
"description": "The list of locations that resource groups can be created in.",
"strongType": "location",
"displayName": "Allowed locations"
}
},
"effect": {
"type": "String",
"defaultValue": "Deny",
"allowedValues": [
"Audit",
"Deny",
"Disabled"
],
"metadata": {
"displayName": "Effect",
"description": "Enable or disable the execution of the policy"
}
}
},
"policyRule": {
"if": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.Resources/subscriptions/resourceGroups"
},
{
"field": "location",
"notIn": "[parameters('listOfAllowedLocations')]"
}
]
},
"then": {
"effect": "[parameters('effect')]"
}
},
"versions": [
"1.1.0",
"1.0.0"
]
},
"id": "/providers/Microsoft.Authorization/policyDefinitions/e765b5de-1225-4ba3-bd56-1ac6695af988",
"name": "e765b5de-1225-4ba3-bd56-1ac6695af988"
}Bylawe765b5de-1225-4ba3-bd56-1ac6695af988.bylaw.ps1 · 34 lines
# Converted from ResourceGroupAllowedLocations_Deny.json by ConvertTo-Bylaw.
Policy 'e765b5de-1225-4ba3-bd56-1ac6695af988' {
Properties @{
DisplayName = 'Allowed locations for resource groups'
Description = 'This policy enables you to restrict the locations your organization can create resource groups in. Use to enforce your geo-compliance requirements.'
Version = '1.1.0'
Category = 'General'
PolicyVersion = '1.1.0'
Mode = 'All'
}
Parameter ListOfAllowedLocations @{
Type = 'Array'
DisplayName = 'Allowed locations'
Description = 'The list of locations that resource groups can be created in.'
Metadata = [ordered]@{ strongType = 'location' }
}
Parameter Effect @{
AllowedValues = @('Audit', 'Deny', 'Disabled')
Default = 'Deny'
DisplayName = 'Effect'
Description = 'Enable or disable the execution of the policy'
}
Resource 'Microsoft.Resources/subscriptions/resourceGroups' {
Require 'location is one of the ListOfAllowedLocations parameter' {
Field location | Must -BeIn (Param ListOfAllowedLocations)
}
}
Effect (Param Effect)
}Source: built-in-policies/policyDefinitions/General/ResourceGroupAllowedLocations_Deny.json in Azure/azure-policy, under the MIT licence.
Bylaw