Bylaw

Gallery › Sovereignty › Azure built-in policies

[Preview]: Azure Communication Services should disable public network access

Converted Policy Audit Deny Disabled Mode Indexed Version 1.0.0-preview Preview

Disabling public network access helps reduce exposure of Azure Communication Services resources to the public internet.

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

Azure Policy JSONCommunication_PublicNetworkAccess_Audit.json · 59 lines
{
  "properties": {
    "displayName": "[Preview]: Azure Communication Services should disable public network access",
    "description": "Disabling public network access helps reduce exposure of Azure Communication Services resources to the public internet.",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "metadata": {
      "version": "1.0.0-preview",
      "category": "Sovereignty",
      "preview": true
    },
    "version": "1.0.0-preview",
    "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.Communication/CommunicationServices"
          },
          {
            "anyOf": [
              {
                "field": "Microsoft.Communication/communicationServices/publicNetworkAccess",
                "exists": "false"
              },
              {
                "field": "Microsoft.Communication/communicationServices/publicNetworkAccess",
                "notEquals": "Disabled"
              }
            ]
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "versions": [
      "1.0.0-PREVIEW"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/c4225fe7-a11b-4e6b-8f9c-989dd2907bd2",
  "name": "c4225fe7-a11b-4e6b-8f9c-989dd2907bd2"
}
Bylawc4225fe7-a11b-4e6b-8f9c-989dd2907bd2.bylaw.ps1 · 33 lines
# Converted from Communication_PublicNetworkAccess_Audit.json by ConvertTo-Bylaw.
Policy 'c4225fe7-a11b-4e6b-8f9c-989dd2907bd2' {

    Properties @{
        DisplayName   = '[Preview]: Azure Communication Services should disable public network access'
        Description   = 'Disabling public network access helps reduce exposure of Azure Communication Services resources to the public internet.'
        Version       = '1.0.0-preview'
        Category      = 'Sovereignty'
        Preview       = $true
        PolicyVersion = '1.0.0-preview'
        Mode          = 'Indexed'
    }

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

    Resource 'Microsoft.Communication/CommunicationServices' {

        Require 'publicNetworkAccess exists' {
            Field publicNetworkAccess | Must -Exist
        }

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

    Effect (Param Effect)
}

Source: built-in-policies/policyDefinitions/Sovereignty/Communication_PublicNetworkAccess_Audit.json in Azure/azure-policy, under the MIT licence.