Bylaw

Gallery › Desktop Virtualization › Azure built-in policies

Azure Virtual Desktop hostpools should disable public network access

Converted Policy Audit Deny Disabled Mode Indexed Version 1.0.0

Disabling public network access improves security and keeps your data safe by ensuring that access to the Azure Virtual Desktop service is not exposed to the public internet. Learn more at: https://aka.ms/avdprivatelink.

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

Azure Policy JSONHostpool_PrivateNetworkOnly_AuditDeny.json · 50 lines
{
  "properties": {
    "displayName": "Azure Virtual Desktop hostpools should disable public network access",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "Disabling public network access improves security and keeps your data safe by ensuring that access to the Azure Virtual Desktop service is not exposed to the public internet. Learn more at: https://aka.ms/avdprivatelink.",
    "metadata": {
      "version": "1.0.0",
      "category": "Desktop Virtualization"
    },
    "version": "1.0.0",
    "parameters": {
      "effect": {
        "type": "String",
        "metadata": {
          "displayName": "Effect",
          "description": "Enable or disable the execution of the policy"
        },
        "allowedValues": [
          "Audit",
          "Deny",
          "Disabled"
        ],
        "defaultValue": "Audit"
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.DesktopVirtualization/hostpools"
          },
          {
            "field": "Microsoft.DesktopVirtualization/hostPools/publicNetworkAccess",
            "notEquals": "Disabled"
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "versions": [
      "1.0.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/c25dcf31-878f-4eba-98eb-0818fdc6a334",
  "name": "c25dcf31-878f-4eba-98eb-0818fdc6a334"
}
Bylawc25dcf31-878f-4eba-98eb-0818fdc6a334.bylaw.ps1 · 28 lines
# Converted from Hostpool_PrivateNetworkOnly_AuditDeny.json by ConvertTo-Bylaw.
Policy 'c25dcf31-878f-4eba-98eb-0818fdc6a334' {

    Properties @{
        DisplayName   = 'Azure Virtual Desktop hostpools should disable public network access'
        Description   = 'Disabling public network access improves security and keeps your data safe by ensuring that access to the Azure Virtual Desktop service is not exposed to the public internet. Learn more at: https://aka.ms/avdprivatelink.'
        Version       = '1.0.0'
        Category      = 'Desktop Virtualization'
        PolicyVersion = '1.0.0'
        Mode          = 'Indexed'
    }

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

    Resource 'Microsoft.DesktopVirtualization/hostpools' {

        Require 'publicNetworkAccess is Disabled' {
            Field publicNetworkAccess | Must -Be 'Disabled'
        }
    }

    Effect (Param Effect)
}

Source: built-in-policies/policyDefinitions/Desktop Virtualization/Hostpool_PrivateNetworkOnly_AuditDeny.json in Azure/azure-policy, under the MIT licence.