Bylaw

Gallery › App Configuration › Azure built-in policies

Configure App Configuration to disable public network access

Converted Policy Disabled Modify Mode Indexed Version 1.0.0

Disable public network access for App Configuration so that it isn't accessible over the public internet. This configuration helps protect them against data leakage risks. You can limit exposure of the your resources by creating private endpoints instead. Learn more at: https://aka.ms/appconfig/private-endpoint.

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

Azure Policy JSONPrivateLink_PublicNetworkAccess_Modify.json · 63 lines
{
  "properties": {
    "displayName": "Configure App Configuration to disable public network access",
    "description": "Disable public network access for App Configuration so that it isn't accessible over the public internet. This configuration helps protect them against data leakage risks. You can limit exposure of the your resources by creating private endpoints instead. Learn more at: https://aka.ms/appconfig/private-endpoint.",
    "metadata": {
      "version": "1.0.0",
      "category": "App Configuration"
    },
    "version": "1.0.0",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "parameters": {
      "effect": {
        "type": "String",
        "metadata": {
          "displayName": "Effect",
          "description": "Enable or disable the execution of the policy"
        },
        "allowedValues": [
          "Modify",
          "Disabled"
        ],
        "defaultValue": "Modify"
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.AppConfiguration/configurationStores"
          },
          {
            "field": "Microsoft.AppConfiguration/configurationStores/publicNetworkAccess",
            "notEquals": "Disabled"
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]",
        "details": {
          "roleDefinitionIds": [
            "/providers/microsoft.authorization/roleDefinitions/b24988ac-6180-42a0-ab88-20f7382dd24c"
          ],
          "conflictEffect": "audit",
          "operations": [
            {
              "condition": "[greater(requestContext().apiVersion, '2019-10-01')]",
              "operation": "addOrReplace",
              "field": "Microsoft.AppConfiguration/configurationStores/publicNetworkAccess",
              "value": "Disabled"
            }
          ]
        }
      }
    },
    "versions": [
      "1.0.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/73290fa2-dfa7-4bbb-945d-a5e23b75df2c",
  "name": "73290fa2-dfa7-4bbb-945d-a5e23b75df2c"
}
Bylaw73290fa2-dfa7-4bbb-945d-a5e23b75df2c.bylaw.ps1 · 30 lines
# Converted from PrivateLink_PublicNetworkAccess_Modify.json by ConvertTo-Bylaw.
Policy '73290fa2-dfa7-4bbb-945d-a5e23b75df2c' {

    Properties @{
        DisplayName   = 'Configure App Configuration to disable public network access'
        Description   = 'Disable public network access for App Configuration so that it isn''t accessible over the public internet. This configuration helps protect them against data leakage risks. You can limit exposure of the your resources by creating private endpoints instead. Learn more at: https://aka.ms/appconfig/private-endpoint.'
        Version       = '1.0.0'
        Category      = 'App Configuration'
        PolicyVersion = '1.0.0'
        Mode          = 'Indexed'
    }

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

    Resource 'Microsoft.AppConfiguration/configurationStores' {

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

    Modify -Role 'Contributor' -ConflictEffect Audit -Effect (Param Effect) {
        Field publicNetworkAccess | AddOrReplace 'Disabled' -Condition (Arm '[greater(requestContext().apiVersion, ''2019-10-01'')]')
    }
}

Source: built-in-policies/policyDefinitions/App Configuration/PrivateLink_PublicNetworkAccess_Modify.json in Azure/azure-policy, under the MIT licence.