Gallery › Compute › Azure built-in policies
Configure disk access resources with private endpoints
Converted Policy DeployIfNotExists Disabled Mode Indexed Version 1.0.0
Private endpoints connect your virtual networks to Azure services without a public IP address at the source or destination. By mapping private endpoints to disk access resources, you can reduce data leakage risks. Learn more about private links at: https://aka.ms/disksprivatelinksdoc.
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONDiskAccesses_PrivateEndpoints_DINE.json · 138 lines
{
"properties": {
"displayName": "Configure disk access resources with private endpoints",
"description": "Private endpoints connect your virtual networks to Azure services without a public IP address at the source or destination. By mapping private endpoints to disk access resources, you can reduce data leakage risks. Learn more about private links at: https://aka.ms/disksprivatelinksdoc.",
"policyType": "BuiltIn",
"mode": "Indexed",
"metadata": {
"version": "1.0.0",
"category": "Compute"
},
"version": "1.0.0",
"parameters": {
"effect": {
"type": "String",
"metadata": {
"displayName": "Effect",
"description": "Enable or disable the execution of the policy"
},
"allowedValues": [
"DeployIfNotExists",
"Disabled"
],
"defaultValue": "DeployIfNotExists"
},
"location": {
"type": "String",
"metadata": {
"displayName": "Location",
"strongType": "location",
"description": "All disk access resources in this region are validated and private endpoints are created in this region."
}
},
"privateEndpointSubnetId": {
"type": "String",
"metadata": {
"displayName": "Private endpoint subnet ID",
"description": "A subnet with private endpoint network policies disabled.",
"strongType": "Microsoft.Network/virtualNetworks/subnets"
}
}
},
"policyRule": {
"if": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.Compute/diskAccesses"
},
{
"field": "location",
"equals": "[parameters('location')]"
}
]
},
"then": {
"effect": "[parameters('effect')]",
"details": {
"type": "Microsoft.Compute/diskAccesses/privateEndpointConnections",
"existenceCondition": {
"field": "Microsoft.Compute/diskAccesses/privateEndpointConnections/privateLinkServiceConnectionState.status",
"equals": "Approved"
},
"roleDefinitionIds": [
"/providers/Microsoft.Authorization/roleDefinitions/b24988ac-6180-42a0-ab88-20f7382dd24c"
],
"deployment": {
"properties": {
"mode": "incremental",
"parameters": {
"name": {
"value": "[concat('pe','-',field('name'))]"
},
"serviceId": {
"value": "[field('id')]"
},
"privateEndpointSubnetId": {
"value": "[parameters('privateEndpointSubnetId')]"
},
"location": {
"value": "[field('location')]"
}
},
"template": {
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"name": {
"type": "string"
},
"serviceId": {
"type": "string"
},
"privateEndpointSubnetId": {
"type": "string"
},
"location": {
"type": "string"
}
},
"resources": [
{
"name": "[parameters('name')]",
"type": "Microsoft.Network/privateEndpoints",
"apiVersion": "2019-11-01",
"location": "[parameters('location')]",
"tags": {},
"properties": {
"subnet": {
"id": "[parameters('privateEndpointSubnetId')]"
},
"privateLinkServiceConnections": [
{
"name": "[parameters('name')]",
"properties": {
"privateLinkServiceId": "[parameters('serviceId')]",
"groupIds": [
"disks"
]
}
}
],
"manualPrivateLinkServiceConnections": []
}
}
]
}
}
}
}
}
},
"versions": [
"1.0.0"
]
},
"id": "/providers/Microsoft.Authorization/policyDefinitions/582bd7a6-a5f6-4dc6-b9dc-9cb81fe0d4c5",
"name": "582bd7a6-a5f6-4dc6-b9dc-9cb81fe0d4c5"
}Bylaw582bd7a6-a5f6-4dc6-b9dc-9cb81fe0d4c5.bylaw.ps1 · 50 lines
# Converted from DiskAccesses_PrivateEndpoints_DINE.json by ConvertTo-Bylaw.
Policy '582bd7a6-a5f6-4dc6-b9dc-9cb81fe0d4c5' {
Properties @{
DisplayName = 'Configure disk access resources with private endpoints'
Description = 'Private endpoints connect your virtual networks to Azure services without a public IP address at the source or destination. By mapping private endpoints to disk access resources, you can reduce data leakage risks. Learn more about private links at: https://aka.ms/disksprivatelinksdoc.'
Version = '1.0.0'
Category = 'Compute'
PolicyVersion = '1.0.0'
Mode = 'Indexed'
}
Parameter Effect @{
AllowedValues = @('DeployIfNotExists', 'Disabled')
Default = 'DeployIfNotExists'
DisplayName = 'Effect'
Description = 'Enable or disable the execution of the policy'
}
Parameter Location @{
Type = 'String'
DisplayName = 'Location'
Description = 'All disk access resources in this region are validated and private endpoints are created in this region.'
Metadata = [ordered]@{ strongType = 'location' }
}
Parameter PrivateEndpointSubnetId @{
Type = 'String'
DisplayName = 'Private endpoint subnet ID'
Description = 'A subnet with private endpoint network policies disabled.'
Metadata = [ordered]@{ strongType = 'Microsoft.Network/virtualNetworks/subnets' }
}
Resource 'Microsoft.Compute/diskAccesses' {
Require 'location is not the Location parameter' {
Field location | Must -Not -Be (Param Location) -IfPresent
}
}
DeployIfNotExists 'Microsoft.Compute/diskAccesses/privateEndpointConnections' -Role 'Contributor' -Effect (Param Effect) {
Require 'privateLinkServiceConnectionState.status is Approved' {
Field privateLinkServiceConnectionState.status | Must -Be 'Approved'
}
Deployment -TemplateFile './templates/582bd7a6-a5f6-4dc6-b9dc-9cb81fe0d4c5.json' -Parameters ([ordered]@{
name = (Arm '[concat(''pe'',''-'',field(''name''))]')
serviceId = (Arm '[field(''id'')]')
privateEndpointSubnetId = (Param PrivateEndpointSubnetId)
location = (Arm '[field(''location'')]')
})
}
}Its deployment templates are written beside it:
templates/582bd7a6-a5f6-4dc6-b9dc-9cb81fe0d4c5.json
Source: built-in-policies/policyDefinitions/Compute/DiskAccesses_PrivateEndpoints_DINE.json in Azure/azure-policy, under the MIT licence.
Bylaw