Bylaw

Gallery › Media Services › Azure built-in policies

[Deprecated]: Configure Azure Media Services to use private DNS zones

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 JSONPrivateLinkDns_DINE.json · 141 lines
{
  "properties": {
    "displayName": "[Deprecated]: Configure Azure Media Services to use private DNS zones",
    "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": {
      "privateDnsZoneId": {
        "type": "String",
        "metadata": {
          "displayName": "Private DNS Zone ID for Media Services",
          "description": "The private DNS zone name required for Media Services to resolve a private DNS Zone.",
          "strongType": "Microsoft.Network/privateDnsZones",
          "assignPermissions": true
        }
      },
      "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": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.Network/privateEndpoints"
          },
          {
            "count": {
              "field": "Microsoft.Network/privateEndpoints/privateLinkServiceConnections[*]",
              "where": {
                "allOf": [
                  {
                    "field": "Microsoft.Network/privateEndpoints/privateLinkServiceConnections[*].privateLinkServiceId",
                    "contains": "Microsoft.Media/mediaservices"
                  },
                  {
                    "field": "Microsoft.Network/privateEndpoints/privateLinkServiceConnections[*].groupIds[*]",
                    "equals": "[parameters('groupId')]"
                  }
                ]
              }
            },
            "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": {
                  "privateDnsZoneId": {
                    "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": "mediaservices-privateDnsZone",
                          "properties": {
                            "privateDnsZoneId": "[parameters('privateDnsZoneId')]"
                          }
                        }
                      ]
                    }
                  }
                ]
              },
              "parameters": {
                "privateDnsZoneId": {
                  "value": "[parameters('privateDnsZoneId')]"
                },
                "privateEndpointName": {
                  "value": "[field('name')]"
                },
                "location": {
                  "value": "[field('location')]"
                }
              }
            }
          }
        }
      }
    },
    "versions": [
      "1.1.0",
      "1.0.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/b4a7f6c1-585e-4177-ad5b-c2c93f4bb991",
  "name": "b4a7f6c1-585e-4177-ad5b-c2c93f4bb991"
}
Bylawb4a7f6c1-585e-4177-ad5b-c2c93f4bb991.bylaw.ps1 · 53 lines
# Converted from PrivateLinkDns_DINE.json by ConvertTo-Bylaw.
Policy 'b4a7f6c1-585e-4177-ad5b-c2c93f4bb991' {

    Properties @{
        DisplayName   = '[Deprecated]: Configure Azure Media Services to use private DNS zones'
        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 PrivateDnsZoneId @{
        Type        = 'String'
        DisplayName = 'Private DNS Zone ID for Media Services'
        Description = 'The private DNS zone name required for Media Services to resolve a private DNS Zone.'
        Metadata    = [ordered]@{ strongType = 'Microsoft.Network/privateDnsZones'; assignPermissions = $true }
    }
    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.Network/privateEndpoints' {

        Require 'privateLinkServiceConnections, privateLinkServiceId and groupIds are as required' {
            Count 'privateLinkServiceConnections[*]' -Where {
                Field privateLinkServiceId | Must -ContainText 'Microsoft.Media/mediaservices'
                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' -Effect (Param Effect) {
        Deployment -TemplateFile './templates/b4a7f6c1-585e-4177-ad5b-c2c93f4bb991.json' -Parameters ([ordered]@{
                privateDnsZoneId    = (Param PrivateDnsZoneId)
                privateEndpointName = (Arm '[field(''name'')]')
                location            = (Arm '[field(''location'')]')
            })
    }
}

Its deployment templates are written beside it:

Source: built-in-policies/policyDefinitions/Media Services/PrivateLinkDns_DINE.json in Azure/azure-policy, under the MIT licence.