Gallery › Networking › Azure Landing Zones Library
Deploy-Private-DNS-Generic
Converted Policy DeployIfNotExists Disabled Mode All Version 2.1.0
Configure private DNS zone group to override the DNS resolution for PaaS services private endpoint. See https://aka.ms/pepdnszones for information on values to provide to parameters in this policy.
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONDeploy-Private-DNS-Generic.alz_policy_definition.json · 187 lines
{
"name": "Deploy-Private-DNS-Generic",
"properties": {
"description": "Configure private DNS zone group to override the DNS resolution for PaaS services private endpoint. See https://aka.ms/pepdnszones for information on values to provide to parameters in this policy.",
"displayName": "Deploy-Private-DNS-Generic",
"metadata": {
"alzCloudEnvironments": [
"AzureCloud",
"AzureChinaCloud",
"AzureUSGovernment"
],
"category": "Networking",
"source": "https://github.com/Azure/Enterprise-Scale/",
"version": "2.1.0"
},
"mode": "All",
"parameters": {
"effect": {
"allowedValues": [
"DeployIfNotExists",
"Disabled"
],
"defaultValue": "DeployIfNotExists",
"metadata": {
"description": "Enable or disable the execution of the policy",
"displayName": "Effect"
},
"type": "String"
},
"evaluationDelay": {
"defaultValue": "PT10M",
"metadata": {
"description": "The delay in evaluation of the policy. Review delay options at https://learn.microsoft.com/en-us/azure/governance/policy/concepts/effect-deploy-if-not-exists",
"displayName": "Evaluation Delay"
},
"type": "String"
},
"groupId": {
"metadata": {
"description": "The group ID of the PaaS private endpoint. Also referred to as subresource.",
"displayName": "PaaS Private endpoint group ID (subresource)"
},
"type": "String"
},
"location": {
"defaultValue": "northeurope",
"metadata": {
"description": "Specify the Private Endpoint location",
"displayName": "Location (Specify the Private Endpoint location)",
"strongType": "location"
},
"type": "String"
},
"privateDnsZoneId": {
"metadata": {
"assignPermissions": true,
"description": "The private DNS zone name required for specific PaaS Services to resolve a private DNS Zone.",
"displayName": "Private DNS Zone ID for PaaS services",
"strongType": "Microsoft.Network/privateDnsZones"
},
"type": "String"
},
"resourceType": {
"metadata": {
"description": "The PaaS endpoint resource type.",
"displayName": "PaaS private endpoint resource type"
},
"type": "String"
}
},
"policyRule": {
"if": {
"allOf": [
{
"equals": "[parameters('location')]",
"field": "location"
},
{
"equals": "Microsoft.Network/privateEndpoints",
"field": "type"
},
{
"anyOf": [
{
"count": {
"field": "Microsoft.Network/privateEndpoints/privateLinkServiceConnections[*]",
"where": {
"allOf": [
{
"contains": "[parameters('resourceType')]",
"field": "Microsoft.Network/privateEndpoints/privateLinkServiceConnections[*].privateLinkServiceId"
},
{
"equals": "[parameters('groupId')]",
"field": "Microsoft.Network/privateEndpoints/privateLinkServiceConnections[*].groupIds[*]"
}
]
}
},
"greaterOrEquals": 1
},
{
"count": {
"field": "Microsoft.Network/privateEndpoints/manualPrivateLinkServiceConnections[*]",
"where": {
"allOf": [
{
"contains": "[parameters('resourceType')]",
"field": "Microsoft.Network/privateEndpoints/manualPrivateLinkServiceConnections[*].privateLinkServiceId"
},
{
"equals": "[parameters('groupId')]",
"field": "Microsoft.Network/privateEndpoints/manualPrivateLinkServiceConnections[*].groupIds[*]"
}
]
}
},
"greaterOrEquals": 1
}
]
}
]
},
"then": {
"details": {
"deployment": {
"properties": {
"mode": "incremental",
"parameters": {
"location": {
"value": "[field('location')]"
},
"privateDnsZoneId": {
"value": "[parameters('privateDnsZoneId')]"
},
"privateEndpointName": {
"value": "[field('name')]"
}
},
"template": {
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"location": {
"type": "string"
},
"privateDnsZoneId": {
"type": "string"
},
"privateEndpointName": {
"type": "string"
}
},
"resources": [
{
"apiVersion": "2020-03-01",
"location": "[parameters('location')]",
"name": "[concat(parameters('privateEndpointName'), '/deployedByPolicy')]",
"properties": {
"privateDnsZoneConfigs": [
{
"name": "PaaS-Service-Private-DNS-Zone-Config",
"properties": {
"privateDnsZoneId": "[parameters('privateDnsZoneId')]"
}
}
]
},
"type": "Microsoft.Network/privateEndpoints/privateDnsZoneGroups"
}
]
}
}
},
"evaluationDelay": "[parameters('evaluationDelay')]",
"roleDefinitionIds": [
"/providers/Microsoft.Authorization/roleDefinitions/4d97b98b-1d4f-4787-a291-c67834d212e7"
],
"type": "Microsoft.Network/privateEndpoints/privateDnsZoneGroups"
},
"effect": "[parameters('effect')]"
}
},
"policyType": "Custom"
},
"type": "Microsoft.Authorization/policyDefinitions"
}BylawDeploy-Private-DNS-Generic.bylaw.ps1 · 81 lines
# Converted from Deploy-Private-DNS-Generic.alz_policy_definition.json by ConvertTo-Bylaw.
Policy 'Deploy-Private-DNS-Generic' {
Properties @{
DisplayName = 'Deploy-Private-DNS-Generic'
Description = 'Configure private DNS zone group to override the DNS resolution for PaaS services private endpoint. See https://aka.ms/pepdnszones for information on values to provide to parameters in this policy.'
Category = 'Networking'
Version = '2.1.0'
Mode = 'All'
Metadata = [ordered]@{ alzCloudEnvironments = @('AzureCloud', 'AzureChinaCloud', 'AzureUSGovernment'); source = 'https://github.com/Azure/Enterprise-Scale/' }
}
Parameter Effect @{
AllowedValues = @('DeployIfNotExists', 'Disabled')
Default = 'DeployIfNotExists'
DisplayName = 'Effect'
Description = 'Enable or disable the execution of the policy'
}
Parameter EvaluationDelay @{
Default = 'PT10M'
DisplayName = 'Evaluation Delay'
Description = 'The delay in evaluation of the policy. Review delay options at https://learn.microsoft.com/en-us/azure/governance/policy/concepts/effect-deploy-if-not-exists'
}
Parameter GroupId @{
Type = 'String'
DisplayName = 'PaaS Private endpoint group ID (subresource)'
Description = 'The group ID of the PaaS private endpoint. Also referred to as subresource.'
}
Parameter Location @{
Default = 'northeurope'
DisplayName = 'Location (Specify the Private Endpoint location)'
Description = 'Specify the Private Endpoint location'
Metadata = [ordered]@{ strongType = 'location' }
}
Parameter PrivateDnsZoneId @{
Type = 'String'
DisplayName = 'Private DNS Zone ID for PaaS services'
Description = 'The private DNS zone name required for specific PaaS Services to resolve a private DNS Zone.'
Metadata = [ordered]@{ assignPermissions = $true; strongType = 'Microsoft.Network/privateDnsZones' }
}
Parameter ResourceType @{
Type = 'String'
DisplayName = 'PaaS private endpoint resource type'
Description = 'The PaaS endpoint resource type.'
}
Resource 'Microsoft.Network/privateEndpoints' {
When {
Field location | Must -Be (Param Location)
}
Require 'privateLinkServiceConnections, privateLinkServiceId and groupIds are as required' {
Count 'privateLinkServiceConnections[*]' -Where {
Field privateLinkServiceId | Must -ContainText (Param ResourceType)
Field groupIds | Must -Exist
Count 'groupIds[*]' -Where {
Element | Must -Not -Be (Param GroupId)
} | Must -Be 0
} | Must -Be 0
}
Require 'manualPrivateLinkServiceConnections, privateLinkServiceId and groupIds are as required' {
Count 'manualPrivateLinkServiceConnections[*]' -Where {
Field privateLinkServiceId | Must -ContainText (Param ResourceType)
Field groupIds | Must -Exist
Count 'groupIds[*]' -Where {
Element | Must -Not -Be (Param GroupId)
} | Must -Be 0
} | Must -Be 0
}
}
DeployIfNotExists 'Microsoft.Network/privateEndpoints/privateDnsZoneGroups' -Role 'Network Contributor' -EvaluationDelay (Param EvaluationDelay) -Effect (Param Effect) {
Deployment -TemplateFile './templates/Deploy-Private-DNS-Generic.json' -Parameters ([ordered]@{
location = (Arm '[field(''location'')]')
privateDnsZoneId = (Param PrivateDnsZoneId)
privateEndpointName = (Arm '[field(''name'')]')
})
}
}Its deployment templates are written beside it:
templates/Deploy-Private-DNS-Generic.json
Source: policy_definitions/Deploy-Private-DNS-Generic.alz_policy_definition.json in Azure/Azure-Landing-Zones-Library, under the MIT licence.
Bylaw