Bylaw

Gallery › Event Hub › Azure Community Policy

Deny - Configure Event Hubs to use availability zones

Converted Policy Audit Deny Disabled Mode All Version 1.0.0

The policy enforces the usage of regions with availability zones. With availability zones high availability is provided.

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

Azure Policy JSONazurepolicy.json · 45 lines
{
  "name": "45e750b3-fd9e-4079-a63f-2b9e4efa4a4c",
  "type": "Microsoft.Authorization/policyDefinitions",
  "properties": {
    "displayName": "Deny - Configure Event Hubs to use availability zones",
    "description": "The policy enforces the usage of regions with availability zones. With availability zones high availability is provided.",
    "metadata": {
      "category": "Event Hub",
      "version": "1.0.0"
    },
    "mode": "All",
    "parameters": {
      "effect": {
        "type": "String",
        "metadata": {
          "displayName": "Effect",
          "description": "Deny, Audit or Disabled the execution of the Policy"
        },
        "allowedValues": [
          "Deny",
          "Audit",
          "Disabled"
        ],
        "defaultValue": "Audit"
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.EventHub/namespaces"
          },
          {
            "field": "Microsoft.EventHub/namespaces/zoneRedundant",
            "notEquals": true
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    }
  }
}
Bylaw45e750b3-fd9e-4079-a63f-2b9e4efa4a4c.bylaw.ps1 · 27 lines
# Converted from azurepolicy.json by ConvertTo-Bylaw.
Policy '45e750b3-fd9e-4079-a63f-2b9e4efa4a4c' {

    Properties @{
        DisplayName = 'Deny - Configure Event Hubs to use availability zones'
        Description = 'The policy enforces the usage of regions with availability zones. With availability zones high availability is provided.'
        Category    = 'Event Hub'
        Version     = '1.0.0'
        Mode        = 'All'
    }

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

    Resource 'Microsoft.EventHub/namespaces' {

        Require 'zoneRedundant is true' {
            Field zoneRedundant | Must -Be $true
        }
    }

    Effect (Param Effect)
}

Source: policyDefinitions/Event Hub/deny-configure-event-hubs-to-use-availability-zones/azurepolicy.json in Azure/Community-Policy, under the MIT licence.