Gallery › Sovereignty › Azure built-in policies
[Preview]: Azure SQL Managed Instance databases with a default secondary location should use an allowed location
Converted Policy Audit Disabled Mode Indexed Version 1.0.0-preview Preview
Audit Azure SQL Managed Instance databases with a default secondary location when that location is not in the list of allowed locations. This policy does not evaluate the managed instance or database primary location.
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONSqlManagedInstanceDatabase_DefaultSecondaryLocation_Audit.json · 62 lines
{
"properties": {
"displayName": "[Preview]: Azure SQL Managed Instance databases with a default secondary location should use an allowed location",
"policyType": "BuiltIn",
"mode": "Indexed",
"description": "Audit Azure SQL Managed Instance databases with a default secondary location when that location is not in the list of allowed locations. This policy does not evaluate the managed instance or database primary location.",
"metadata": {
"version": "1.0.0-preview",
"category": "Sovereignty",
"preview": true
},
"version": "1.0.0-preview",
"parameters": {
"allowedDefaultSecondaryLocations": {
"type": "Array",
"metadata": {
"displayName": "Allowed default secondary locations",
"description": "The list of allowed default secondary locations for Azure SQL Managed Instance databases.",
"strongType": "location"
}
},
"effect": {
"type": "String",
"metadata": {
"displayName": "Effect",
"description": "Enable or disable the execution of the policy"
},
"allowedValues": [
"Audit",
"Disabled"
],
"defaultValue": "Audit"
}
},
"policyRule": {
"if": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.Sql/managedInstances/databases"
},
{
"field": "Microsoft.Sql/managedInstances/databases/defaultSecondaryLocation",
"exists": true
},
{
"value": "[replace(toLower(field('Microsoft.Sql/managedInstances/databases/defaultSecondaryLocation')), ' ', '')]",
"notIn": "[parameters('allowedDefaultSecondaryLocations')]"
}
]
},
"then": {
"effect": "[parameters('effect')]"
}
},
"versions": [
"1.0.0-PREVIEW"
]
},
"id": "/providers/Microsoft.Authorization/policyDefinitions/25ff226b-1747-454d-8ae2-0c11e0935753",
"name": "25ff226b-1747-454d-8ae2-0c11e0935753"
}Bylaw25ff226b-1747-454d-8ae2-0c11e0935753.bylaw.ps1 · 39 lines
# Converted from SqlManagedInstanceDatabase_DefaultSecondaryLocation_Audit.json by ConvertTo-Bylaw.
Policy '25ff226b-1747-454d-8ae2-0c11e0935753' {
Properties @{
DisplayName = '[Preview]: Azure SQL Managed Instance databases with a default secondary location should use an allowed location'
Description = 'Audit Azure SQL Managed Instance databases with a default secondary location when that location is not in the list of allowed locations. This policy does not evaluate the managed instance or database primary location.'
Version = '1.0.0-preview'
Category = 'Sovereignty'
Preview = $true
PolicyVersion = '1.0.0-preview'
Mode = 'Indexed'
}
Parameter AllowedDefaultSecondaryLocations @{
Type = 'Array'
DisplayName = 'Allowed default secondary locations'
Description = 'The list of allowed default secondary locations for Azure SQL Managed Instance databases.'
Metadata = [ordered]@{ strongType = 'location' }
}
Parameter Effect @{
AllowedValues = @('Audit', 'Disabled')
Default = 'Audit'
DisplayName = 'Effect'
Description = 'Enable or disable the execution of the policy'
}
Resource 'Microsoft.Sql/managedInstances/databases' {
When {
Field defaultSecondaryLocation | Must -Exist
}
Require 'defaultSecondaryLocation is as required' {
Arm '[replace(toLower(field(''Microsoft.Sql/managedInstances/databases/defaultSecondaryLocation'')), '' '', '''')]' | Must -BeIn (Param AllowedDefaultSecondaryLocations)
}
}
Effect (Param Effect)
}Source: built-in-policies/policyDefinitions/Sovereignty/SqlManagedInstanceDatabase_DefaultSecondaryLocation_Audit.json in Azure/azure-policy, under the MIT licence.
Bylaw