Gallery › Backup › Azure built-in policies
Configure Recovery Services vaults to use private DNS zones for backup
Converted Policy DeployIfNotExists Disabled Mode Indexed Version 1.0.2
Use private DNS zones to override the DNS resolution for a private endpoint. A private DNS zone links to your virtual network to resolve to your Recovery Services vault. Learn more at: https://aka.ms/AB-PrivateEndpoints.
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONAzBackupRSVault_PeDnsConfigDINE.json · 170 lines
{
"properties": {
"displayName": "Configure Recovery Services vaults to use private DNS zones for backup",
"description": "Use private DNS zones to override the DNS resolution for a private endpoint. A private DNS zone links to your virtual network to resolve to your Recovery Services vault. Learn more at: https://aka.ms/AB-PrivateEndpoints.",
"policyType": "BuiltIn",
"mode": "Indexed",
"metadata": {
"version": "1.0.2",
"category": "Backup"
},
"version": "1.0.2",
"parameters": {
"privateDnsZone-Backup": {
"type": "String",
"metadata": {
"displayName": "Private DNS Zone ID for backup",
"description": "Specifies private DNS Zone ID required to resolve DNS to private IP for the Azure Backup service.",
"strongType": "Microsoft.Network/privateDnsZones",
"assignPermissions": true
}
},
"privateDnsZone-Blob": {
"type": "String",
"metadata": {
"displayName": "Private DNS Zone ID for blobs",
"description": "Specifies private DNS Zone ID required to resolve DNS to private IP for the Azure Blob service.",
"strongType": "Microsoft.Network/privateDnsZones",
"assignPermissions": true
}
},
"privateDnsZone-Queue": {
"type": "String",
"metadata": {
"displayName": "Private DNS Zone ID for queues",
"description": "Specifies private DNS Zone ID required to resolve DNS to private IP for the Azure Queue service.",
"strongType": "Microsoft.Network/privateDnsZones",
"assignPermissions": true
}
},
"effect": {
"type": "String",
"metadata": {
"displayName": "Effect",
"description": "Enable or disable the execution of the policy."
},
"allowedValues": [
"DeployIfNotExists",
"Disabled"
],
"defaultValue": "DeployIfNotExists"
}
},
"policyRule": {
"if": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.Network/privateEndpoints"
},
{
"count": {
"field": "Microsoft.Network/privateEndpoints/privateLinkServiceConnections[*]",
"where": {
"allOf": [
{
"field": "Microsoft.Network/privateEndpoints/privateLinkServiceConnections[*].privateLinkServiceId",
"contains": "Microsoft.RecoveryServices/vaults"
},
{
"field": "Microsoft.Network/privateEndpoints/privateLinkServiceConnections[*].groupIds[*]",
"equals": "AzureBackup"
}
]
}
},
"greaterOrEquals": 1
}
]
},
"then": {
"effect": "[parameters('effect')]",
"details": {
"type": "Microsoft.Network/privateEndpoints/privateDnsZoneGroups",
"roleDefinitionIds": [
"/providers/Microsoft.Authorization/roleDefinitions/4d97b98b-1d4f-4787-a291-c67834d212e7"
],
"deployment": {
"properties": {
"mode": "incremental",
"template": {
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"privateDnsZone-Backup": {
"type": "string"
},
"privateDnsZone-Blob": {
"type": "string"
},
"privateDnsZone-Queue": {
"type": "string"
},
"privateEndpointName": {
"type": "string"
},
"location": {
"type": "string"
}
},
"resources": [
{
"name": "[concat(parameters('privateEndpointName'), '/deployedByPolicy')]",
"type": "Microsoft.Network/privateEndpoints/privateDnsZoneGroups",
"apiVersion": "2020-03-01",
"location": "[parameters('location')]",
"properties": {
"privateDnsZoneConfigs": [
{
"name": "privateDnsZone-Backup",
"properties": {
"privateDnsZoneId": "[parameters('privateDnsZone-Backup')]"
}
},
{
"name": "privateDnsZone-Blob",
"properties": {
"privateDnsZoneId": "[parameters('privateDnsZone-Blob')]"
}
},
{
"name": "privateDnsZone-Queue",
"properties": {
"privateDnsZoneId": "[parameters('privateDnsZone-Queue')]"
}
}
]
}
}
]
},
"parameters": {
"privateDnsZone-Backup": {
"value": "[parameters('privateDnsZone-Backup')]"
},
"privateDnsZone-Blob": {
"value": "[parameters('privateDnsZone-Blob')]"
},
"privateDnsZone-Queue": {
"value": "[parameters('privateDnsZone-Queue')]"
},
"privateEndpointName": {
"value": "[field('name')]"
},
"location": {
"value": "[field('location')]"
}
}
}
}
}
}
},
"versions": [
"1.0.2",
"1.0.1-PREVIEW"
]
},
"id": "/providers/Microsoft.Authorization/policyDefinitions/af783da1-4ad1-42be-800d-d19c70038820",
"name": "af783da1-4ad1-42be-800d-d19c70038820"
}Bylawaf783da1-4ad1-42be-800d-d19c70038820.bylaw.ps1 · 63 lines
# Converted from AzBackupRSVault_PeDnsConfigDINE.json by ConvertTo-Bylaw.
Policy 'af783da1-4ad1-42be-800d-d19c70038820' {
Properties @{
DisplayName = 'Configure Recovery Services vaults to use private DNS zones for backup'
Description = 'Use private DNS zones to override the DNS resolution for a private endpoint. A private DNS zone links to your virtual network to resolve to your Recovery Services vault. Learn more at: https://aka.ms/AB-PrivateEndpoints.'
Version = '1.0.2'
Category = 'Backup'
PolicyVersion = '1.0.2'
Mode = 'Indexed'
}
Parameter PrivateDnsZone_Backup @{
Type = 'String'
DisplayName = 'Private DNS Zone ID for backup'
Description = 'Specifies private DNS Zone ID required to resolve DNS to private IP for the Azure Backup service.'
JsonName = 'privateDnsZone-Backup'
Metadata = [ordered]@{ strongType = 'Microsoft.Network/privateDnsZones'; assignPermissions = $true }
}
Parameter PrivateDnsZone_Blob @{
Type = 'String'
DisplayName = 'Private DNS Zone ID for blobs'
Description = 'Specifies private DNS Zone ID required to resolve DNS to private IP for the Azure Blob service.'
JsonName = 'privateDnsZone-Blob'
Metadata = [ordered]@{ strongType = 'Microsoft.Network/privateDnsZones'; assignPermissions = $true }
}
Parameter PrivateDnsZone_Queue @{
Type = 'String'
DisplayName = 'Private DNS Zone ID for queues'
Description = 'Specifies private DNS Zone ID required to resolve DNS to private IP for the Azure Queue service.'
JsonName = 'privateDnsZone-Queue'
Metadata = [ordered]@{ strongType = 'Microsoft.Network/privateDnsZones'; assignPermissions = $true }
}
Parameter Effect @{
AllowedValues = @('DeployIfNotExists', 'Disabled')
Default = 'DeployIfNotExists'
DisplayName = 'Effect'
Description = 'Enable or disable the execution of the policy.'
}
Resource 'Microsoft.Network/privateEndpoints' {
Require 'privateLinkServiceConnections, privateLinkServiceId and groupIds are as required' {
Count 'privateLinkServiceConnections[*]' -Where {
Field privateLinkServiceId | Must -ContainText 'Microsoft.RecoveryServices/vaults'
Field groupIds | Must -Exist
Count 'groupIds[*]' -Where {
Element | Must -Not -Be 'AzureBackup'
} | Must -Be 0
} | Must -Be 0
}
}
DeployIfNotExists 'Microsoft.Network/privateEndpoints/privateDnsZoneGroups' -Role 'Network Contributor' -Effect (Param Effect) {
Deployment -TemplateFile './templates/af783da1-4ad1-42be-800d-d19c70038820.json' -Parameters ([ordered]@{
'privateDnsZone-Backup' = (Param PrivateDnsZone_Backup)
'privateDnsZone-Blob' = (Param PrivateDnsZone_Blob)
'privateDnsZone-Queue' = (Param PrivateDnsZone_Queue)
privateEndpointName = (Arm '[field(''name'')]')
location = (Arm '[field(''location'')]')
})
}
}Its deployment templates are written beside it:
templates/af783da1-4ad1-42be-800d-d19c70038820.json
Source: built-in-policies/policyDefinitions/Backup/AzBackupRSVault_PeDnsConfigDINE.json in Azure/azure-policy, under the MIT licence.
Bylaw