Bylaw

Gallery › Event Grid › Azure built-in policies

Azure Event Grid domains should disable public network access

Converted Policy Audit Deny Disabled Mode Indexed Version 1.0.0

Disabling public network access improves security by ensuring that the resource isn't exposed on the public internet. You can limit exposure of your resources by creating private endpoints instead. Learn more at: https://aka.ms/privateendpoints.

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

Azure Policy JSONDomains_PublicNetworkAccess_AuditDeny.json · 50 lines
{
  "properties": {
    "displayName": "Azure Event Grid domains should disable public network access",
    "description": "Disabling public network access improves security by ensuring that the resource isn't exposed on the public internet. You can limit exposure of your resources by creating private endpoints instead. Learn more at: https://aka.ms/privateendpoints.",
    "metadata": {
      "version": "1.0.0",
      "category": "Event Grid"
    },
    "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": [
          "Audit",
          "Deny",
          "Disabled"
        ],
        "defaultValue": "Audit"
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.EventGrid/domains"
          },
          {
            "field": "Microsoft.EventGrid/domains/publicNetworkAccess",
            "notEquals": "Disabled"
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "versions": [
      "1.0.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/f8f774be-6aee-492a-9e29-486ef81f3a68",
  "name": "f8f774be-6aee-492a-9e29-486ef81f3a68"
}
Bylawf8f774be-6aee-492a-9e29-486ef81f3a68.bylaw.ps1 · 28 lines
# Converted from Domains_PublicNetworkAccess_AuditDeny.json by ConvertTo-Bylaw.
Policy 'f8f774be-6aee-492a-9e29-486ef81f3a68' {

    Properties @{
        DisplayName   = 'Azure Event Grid domains should disable public network access'
        Description   = 'Disabling public network access improves security by ensuring that the resource isn''t exposed on the public internet. You can limit exposure of your resources by creating private endpoints instead. Learn more at: https://aka.ms/privateendpoints.'
        Version       = '1.0.0'
        Category      = 'Event Grid'
        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.EventGrid/domains' {

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

    Effect (Param Effect)
}

Source: built-in-policies/policyDefinitions/Event Grid/Domains_PublicNetworkAccess_AuditDeny.json in Azure/azure-policy, under the MIT licence.