Gallery › Media Services › Azure built-in policies
[Deprecated]: Configure Azure Media Services with private endpoints
Converted Policy DeployIfNotExists Disabled Mode Indexed Version 1.1.0-deprecated Deprecated
This policy is deprecated because Media Services retirement. Learn more about policy definition deprecation at aka.ms/policydefdeprecation.
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONPrivateLink_DINE.json · 212 lines
{
"properties": {
"displayName": "[Deprecated]: Configure Azure Media Services with private endpoints",
"policyType": "BuiltIn",
"mode": "Indexed",
"description": "This policy is deprecated because Media Services retirement. Learn more about policy definition deprecation at aka.ms/policydefdeprecation.",
"metadata": {
"version": "1.1.0-deprecated",
"category": "Media Services",
"deprecated": true
},
"version": "1.1.0",
"parameters": {
"privateEndpointSubnetId": {
"type": "String",
"metadata": {
"displayName": "Private endpoint subnet ID",
"description": "A subnet with private endpoint network policies disabled.",
"strongType": "Microsoft.Network/virtualNetworks/subnets"
}
},
"groupId": {
"type": "String",
"metadata": {
"displayName": "Private endpoint group ID",
"description": "The group ID of the private endpoint."
},
"allowedValues": [
"keydelivery",
"liveevent",
"streamingendpoint"
]
},
"effect": {
"type": "String",
"metadata": {
"displayName": "Effect",
"description": "Enable or disable the execution of the policy"
},
"allowedValues": [
"DeployIfNotExists",
"Disabled"
],
"defaultValue": "Disabled"
}
},
"policyRule": {
"if": {
"field": "type",
"equals": "Microsoft.Media/mediaservices"
},
"then": {
"effect": "[parameters('effect')]",
"details": {
"type": "Microsoft.Network/privateEndpoints",
"existenceScope": "Subscription",
"existenceCondition": {
"allOf": [
{
"count": {
"field": "Microsoft.Network/privateEndpoints/privateLinkServiceConnections[*]",
"where": {
"allOf": [
{
"field": "Microsoft.Network/privateEndpoints/privateLinkServiceConnections[*].privateLinkServiceId",
"equals": "[field('id')]"
},
{
"field": "Microsoft.Network/privateEndpoints/privateLinkServiceConnections[*].groupIds[*]",
"equals": "[parameters('groupId')]"
}
]
}
},
"greaterOrEquals": 1
},
{
"field": "Microsoft.Network/privateEndpoints/subnet.id",
"equals": "[parameters('privateEndpointSubnetId')]"
}
]
},
"roleDefinitionIds": [
"/providers/Microsoft.Authorization/roleDefinitions/4d97b98b-1d4f-4787-a291-c67834d212e7",
"/providers/Microsoft.Authorization/roleDefinitions/054126f8-9a2b-4f1c-a9ad-eca461f08466"
],
"deployment": {
"properties": {
"mode": "incremental",
"parameters": {
"name": {
"value": "[field('name')]"
},
"serviceId": {
"value": "[field('id')]"
},
"privateEndpointSubnetId": {
"value": "[parameters('privateEndpointSubnetId')]"
},
"groupId": {
"value": "[parameters('groupId')]"
}
},
"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"
},
"groupId": {
"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"
},
"groupId": {
"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": [
"[parameters('groupId')]"
],
"requestMessage": "autoapprove"
}
}
],
"manualPrivateLinkServiceConnections": []
}
}
]
},
"parameters": {
"serviceId": {
"value": "[parameters('serviceId')]"
},
"privateEndpointSubnetId": {
"value": "[parameters('privateEndpointSubnetId')]"
},
"groupId": {
"value": "[parameters('groupId')]"
},
"subnetLocation": {
"value": "[reference(first(take(split(parameters('privateEndpointSubnetId'),'/subnets'),1)),'2020-07-01','Full').location]"
}
}
}
}
]
}
}
}
}
}
},
"versions": [
"1.1.0",
"1.0.0"
]
},
"id": "/providers/Microsoft.Authorization/policyDefinitions/c5632066-946d-4766-9544-cd79bcc1286e",
"name": "c5632066-946d-4766-9544-cd79bcc1286e"
}Bylawc5632066-946d-4766-9544-cd79bcc1286e.bylaw.ps1 · 53 lines
# Converted from PrivateLink_DINE.json by ConvertTo-Bylaw.
Policy 'c5632066-946d-4766-9544-cd79bcc1286e' {
Properties @{
DisplayName = '[Deprecated]: Configure Azure Media Services with private endpoints'
Description = 'This policy is deprecated because Media Services retirement. Learn more about policy definition deprecation at aka.ms/policydefdeprecation.'
Version = '1.1.0-deprecated'
Category = 'Media Services'
Deprecated = $true
PolicyVersion = '1.1.0'
Mode = 'Indexed'
}
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' }
}
Parameter GroupId @{
Type = 'String'
AllowedValues = @('keydelivery', 'liveevent', 'streamingendpoint')
DisplayName = 'Private endpoint group ID'
Description = 'The group ID of the private endpoint.'
}
Parameter Effect @{
AllowedValues = @('DeployIfNotExists', 'Disabled')
Default = 'Disabled'
DisplayName = 'Effect'
Description = 'Enable or disable the execution of the policy'
}
Resource 'Microsoft.Media/mediaservices'
DeployIfNotExists 'Microsoft.Network/privateEndpoints' -Role 'Network Contributor', '054126f8-9a2b-4f1c-a9ad-eca461f08466' -ExistenceScope Subscription -Effect (Param Effect) {
Require 'privateLinkServiceConnections, privateLinkServiceId, groupIds and 2 more are as required' {
Count 'privateLinkServiceConnections[*]' -Where {
Field privateLinkServiceId | Must -Be (Arm '[field(''id'')]')
Field groupIds | Must -Exist
Count 'groupIds[*]' -Where {
Element | Must -Not -Be (Param GroupId)
} | Must -Be 0
} | Must -BeGreaterOrEqual 1
Field subnet.id | Must -Be (Param PrivateEndpointSubnetId)
}
Deployment -TemplateFile './templates/c5632066-946d-4766-9544-cd79bcc1286e.json' -Parameters ([ordered]@{
name = (Arm '[field(''name'')]')
serviceId = (Arm '[field(''id'')]')
privateEndpointSubnetId = (Param PrivateEndpointSubnetId)
groupId = (Param GroupId)
})
}
}Its deployment templates are written beside it:
templates/c5632066-946d-4766-9544-cd79bcc1286e.json
Source: built-in-policies/policyDefinitions/Media Services/PrivateLink_DINE.json in Azure/azure-policy, under the MIT licence.
Bylaw