Bylaw

Gallery › Network › Azure built-in policies

Event Hub should use a virtual network service endpoint

Converted Policy AuditIfNotExists Disabled Mode Indexed Version 1.0.0

This policy audits any Event Hub not configured to use a virtual network service endpoint.

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

Azure Policy JSONVirtualNetworkServiceEndpoint_EventHub_AINE.json · 48 lines
{
  "properties": {
    "displayName": "Event Hub should use a virtual network service endpoint",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "This policy audits any Event Hub not configured to use a virtual network service endpoint.",
    "metadata": {
      "version": "1.0.0",
      "category": "Network"
    },
    "version": "1.0.0",
    "parameters": {
      "effect": {
        "type": "string",
        "defaultValue": "AuditIfNotExists",
        "allowedValues": [
          "AuditIfNotExists",
          "Disabled"
        ],
        "metadata": {
          "displayName": "Effect",
          "description": "Enable or disable the execution of the policy"
        }
      }
    },
    "policyRule": {
      "if": {
        "field": "type",
        "equals": "Microsoft.EventHub/namespaces"
      },
      "then": {
        "effect": "[parameters('effect')]",
        "details": {
          "type": "Microsoft.EventHub/namespaces/virtualNetworkRules",
          "existenceCondition": {
            "field": "Microsoft.EventHub/namespaces/virtualNetworkRules/virtualNetworkSubnetId",
            "exists": "true"
          }
        }
      }
    },
    "versions": [
      "1.0.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/d63edb4a-c612-454d-b47d-191a724fcbf0",
  "name": "d63edb4a-c612-454d-b47d-191a724fcbf0"
}
Bylawd63edb4a-c612-454d-b47d-191a724fcbf0.bylaw.ps1 · 28 lines
# Converted from VirtualNetworkServiceEndpoint_EventHub_AINE.json by ConvertTo-Bylaw.
Policy 'd63edb4a-c612-454d-b47d-191a724fcbf0' {

    Properties @{
        DisplayName   = 'Event Hub should use a virtual network service endpoint'
        Description   = 'This policy audits any Event Hub not configured to use a virtual network service endpoint.'
        Version       = '1.0.0'
        Category      = 'Network'
        PolicyVersion = '1.0.0'
        Mode          = 'Indexed'
    }

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

    Resource 'Microsoft.EventHub/namespaces'

    AuditIfNotExists 'Microsoft.EventHub/namespaces/virtualNetworkRules' -Effect (Param Effect) {
        Require 'virtualNetworkSubnetId exists' {
            Field virtualNetworkSubnetId | Must -Exist
        }
    }
}

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