Gallery › Storage › Azure built-in policies
Configure Azure File Sync with private endpoints
Converted Policy DeployIfNotExists Disabled Mode Indexed Version 1.0.0
A private endpoint is deployed for the indicated Storage Sync Service resource. This enables you to address your Storage Sync Service resource from within the private IP address space of your organization's network, rather than through the internet-accessible public endpoint. The existence of one or more private endpoints by themselves does not disable the public endpoint.
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
{
"properties": {
"displayName": "Configure Azure File Sync with private endpoints",
"description": "A private endpoint is deployed for the indicated Storage Sync Service resource. This enables you to address your Storage Sync Service resource from within the private IP address space of your organization's network, rather than through the internet-accessible public endpoint. The existence of one or more private endpoints by themselves does not disable the public endpoint.",
"policyType": "BuiltIn",
"mode": "Indexed",
"metadata": {
"version": "1.0.0",
"category": "Storage"
},
"version": "1.0.0",
"parameters": {
"privateEndpointSubnetId": {
"type": "String",
"metadata": {
"displayName": "privateEndpointSubnetId",
"description": "A subnet with private endpoint network policies disabled.",
"strongType": "Microsoft.Network/virtualNetworks/subnets"
}
},
"effect": {
"type": "String",
"metadata": {
"displayName": "Effect",
"description": "Enable or disable the execution of the policy"
},
"allowedValues": [
"DeployIfNotExists",
"Disabled"
],
"defaultValue": "DeployIfNotExists"
}
},
"policyRule": {
"if": {
"field": "type",
"equals": "Microsoft.StorageSync/storageSyncServices"
},
"then": {
"effect": "[parameters('effect')]",
"details": {
"type": "Microsoft.StorageSync/storageSyncServices/privateEndpointConnections",
"existenceCondition": {
"field": "Microsoft.StorageSync/storageSyncServices/privateEndpointConnections/privateLinkServiceConnectionState.status",
"equals": "Approved"
},
"roleDefinitionIds": [
"/providers/Microsoft.Authorization/roleDefinitions/b24988ac-6180-42a0-ab88-20f7382dd24c"
],
"deployment": {
"properties": {
"mode": "incremental",
"parameters": {
"name": {
"value": "[field('name')]"
},
"serviceId": {
"value": "[field('id')]"
},
"privateEndpointSubnetId": {
"value": "[parameters('privateEndpointSubnetId')]"
}
},
"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"
}
},
"variables": {
"privateEndpointName": "[concat('pe-',substring(parameters('name'),0,min(length(parameters('name')),50)),'-',uniquestring(deployment().name))]"
},
"resources": [
{
"type": "Microsoft.Resources/deployments",
"name": "[variables('privateEndpointName')]",
"apiVersion": "2020-06-01",
"properties": {
"mode": "Incremental",
"expressionEvaluationOptions": {
"scope": "inner"
},
"template": {
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"serviceId": {
"type": "string"
},
"privateEndpointSubnetId": {
"type": "string"
},
"subnetLocation": {
"type": "string"
}
},
"variables": {
"privateEndpointName": "[deployment().name]"
},
"resources": [
{
"name": "[variables('privateEndpointName')]",
"type": "Microsoft.Network/privateEndpoints",
"apiVersion": "2020-07-01",
"location": "[parameters('subnetLocation')]",
"tags": {},
"properties": {
"subnet": {
"id": "[parameters('privateEndpointSubnetId')]"
},
"privateLinkServiceConnections": [
{
"name": "[variables('privateEndpointName')]",
"properties": {
"privateLinkServiceId": "[parameters('serviceId')]",
"groupIds": [
"afs"
],
"requestMessage": "autoapprove"
}
}
],
"manualPrivateLinkServiceConnections": []
}
}
]
},
"parameters": {
"serviceId": {
"value": "[parameters('serviceId')]"
},
"privateEndpointSubnetId": {
"value": "[parameters('privateEndpointSubnetId')]"
},
"subnetLocation": {
"value": "[reference(first(take(split(parameters('privateEndpointSubnetId'),'/subnets'),1)),'2020-07-01','Full').location]"
}
}
}
}
]
}
}
}
}
}
},
"versions": [
"1.0.0"
]
},
"id": "/providers/Microsoft.Authorization/policyDefinitions/b35dddd9-daf7-423b-8375-5a5b86806d5a",
"name": "b35dddd9-daf7-423b-8375-5a5b86806d5a"
}# Converted from StorageSync_PrivateEndpoint_DINE.json by ConvertTo-Bylaw.
Policy 'b35dddd9-daf7-423b-8375-5a5b86806d5a' {
Properties @{
DisplayName = 'Configure Azure File Sync with private endpoints'
Description = 'A private endpoint is deployed for the indicated Storage Sync Service resource. This enables you to address your Storage Sync Service resource from within the private IP address space of your organization''s network, rather than through the internet-accessible public endpoint. The existence of one or more private endpoints by themselves does not disable the public endpoint.'
Version = '1.0.0'
Category = 'Storage'
PolicyVersion = '1.0.0'
Mode = 'Indexed'
}
Parameter PrivateEndpointSubnetId @{
Type = 'String'
DisplayName = 'privateEndpointSubnetId'
Description = 'A subnet with private endpoint network policies disabled.'
Metadata = [ordered]@{ strongType = 'Microsoft.Network/virtualNetworks/subnets' }
}
Parameter Effect @{
AllowedValues = @('DeployIfNotExists', 'Disabled')
Default = 'DeployIfNotExists'
DisplayName = 'Effect'
Description = 'Enable or disable the execution of the policy'
}
Resource 'Microsoft.StorageSync/storageSyncServices'
DeployIfNotExists 'Microsoft.StorageSync/storageSyncServices/privateEndpointConnections' -Role 'Contributor' -Effect (Param Effect) {
Require 'privateLinkServiceConnectionState.status is Approved' {
Field privateLinkServiceConnectionState.status | Must -Be 'Approved'
}
Deployment -TemplateFile './templates/b35dddd9-daf7-423b-8375-5a5b86806d5a.json' -Parameters ([ordered]@{
name = (Arm '[field(''name'')]')
serviceId = (Arm '[field(''id'')]')
privateEndpointSubnetId = (Param PrivateEndpointSubnetId)
})
}
}Its deployment templates are written beside it:
templates/b35dddd9-daf7-423b-8375-5a5b86806d5a.json
Source: built-in-policies/policyDefinitions/Storage/StorageSync_PrivateEndpoint_DINE.json in Azure/azure-policy, under the MIT licence.
Bylaw