Bylaw

Gallery › VM Image Builder › Azure built-in policies

VM Image Builder templates should use private link

Converted Policy Audit Deny Disabled Mode Indexed Version 1.1.0

Azure Private Link lets you connect your virtual network to Azure services without a public IP address at the source or destination. The Private Link platform handles the connectivity between the consumer and services over the Azure backbone network. By mapping private endpoints to your VM Image Builder building resources, data leakage risks are reduced. Learn more about private links at: https://docs.microsoft.com/azure/virtual-machines/linux/image-builder-networking#deploy-using-an-existing-vnet.

ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.

Azure Policy JSONPrivateLinkEnabled_Audit.json · 50 lines
{
  "properties": {
    "displayName": "VM Image Builder templates should use private link",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "Azure Private Link lets you connect your virtual network to Azure services without a public IP address at the source or destination. The Private Link platform handles the connectivity between the consumer and services over the Azure backbone network. By mapping private endpoints to your VM Image Builder building resources, data leakage risks are reduced. Learn more about private links at: https://docs.microsoft.com/azure/virtual-machines/linux/image-builder-networking#deploy-using-an-existing-vnet.",
    "metadata": {
      "version": "1.1.0",
      "category": "VM Image Builder"
    },
    "version": "1.1.0",
    "parameters": {
      "effect": {
        "type": "String",
        "metadata": {
          "displayName": "Effect",
          "description": "Enable or disable the execution of the policy"
        },
        "allowedValues": [
          "Audit",
          "Disabled",
          "Deny"
        ],
        "defaultValue": "Audit"
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.VirtualMachineImages/imageTemplates"
          },
          {
            "field": "Microsoft.VirtualMachineImages/imageTemplates/vmProfile.vnetConfig",
            "exists": "false"
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "versions": [
      "1.1.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/2154edb9-244f-4741-9970-660785bccdaa",
  "name": "2154edb9-244f-4741-9970-660785bccdaa"
}
Bylaw2154edb9-244f-4741-9970-660785bccdaa.bylaw.ps1 · 28 lines
# Converted from PrivateLinkEnabled_Audit.json by ConvertTo-Bylaw.
Policy '2154edb9-244f-4741-9970-660785bccdaa' {

    Properties @{
        DisplayName   = 'VM Image Builder templates should use private link'
        Description   = 'Azure Private Link lets you connect your virtual network to Azure services without a public IP address at the source or destination. The Private Link platform handles the connectivity between the consumer and services over the Azure backbone network. By mapping private endpoints to your VM Image Builder building resources, data leakage risks are reduced. Learn more about private links at: https://docs.microsoft.com/azure/virtual-machines/linux/image-builder-networking#deploy-using-an-existing-vnet.'
        Version       = '1.1.0'
        Category      = 'VM Image Builder'
        PolicyVersion = '1.1.0'
        Mode          = 'Indexed'
    }

    Parameter Effect @{
        AllowedValues = @('Audit', 'Disabled', 'Deny')
        Default       = 'Audit'
        DisplayName   = 'Effect'
        Description   = 'Enable or disable the execution of the policy'
    }

    Resource 'Microsoft.VirtualMachineImages/imageTemplates' {

        Require 'vmProfile.vnetConfig exists' {
            Field vmProfile.vnetConfig | Must -Exist
        }
    }

    Effect (Param Effect)
}

Source: built-in-policies/policyDefinitions/VM Image Builder/PrivateLinkEnabled_Audit.json in Azure/azure-policy, under the MIT licence.