Bylaw

Gallery › Container Registry › Azure Community Policy

Container Registries enable zone redundancy

Converted Policy Audit Deny Disabled Mode Indexed Version 1.0.0

Ensure registry has zone redundancy, which provides resiliency and high availability to a registry or replication resource (replica) in a specific region.

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

Azure Policy JSONazurepolicy.json · 49 lines
{
  "name": "ce56010a-4601-40cf-98d5-53aab6fd140f",
  "type": "Microsoft.Authorization/policyDefinitions",
  "properties": {
    "displayName": "Container Registries enable zone redundancy",
    "description": "Ensure registry has zone redundancy, which provides resiliency and high availability to a registry or replication resource (replica) in a specific region.",
    "metadata": {
      "category": "Container Registry",
      "version": "1.0.0"
    },
    "mode": "Indexed",
    "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": [
          {
            "equals": "Microsoft.ContainerRegistry/registries",
            "field": "type"
          },
          {
            "in": 
            [
              "disabled",
              "Disabled"
            ],
            "field": "Microsoft.ContainerRegistry/registries/zoneRedundancy"
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    }
  }
}
Bylawce56010a-4601-40cf-98d5-53aab6fd140f.bylaw.ps1 · 27 lines
# Converted from azurepolicy.json by ConvertTo-Bylaw.
Policy 'ce56010a-4601-40cf-98d5-53aab6fd140f' {

    Properties @{
        DisplayName = 'Container Registries enable zone redundancy'
        Description = 'Ensure registry has zone redundancy, which provides resiliency and high availability to a registry or replication resource (replica) in a specific region.'
        Category    = 'Container Registry'
        Version     = '1.0.0'
        Mode        = 'Indexed'
    }

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

    Resource 'Microsoft.ContainerRegistry/registries' {

        Require 'zoneRedundancy is not one of 2 values' {
            Field zoneRedundancy | Must -Not -BeIn @('disabled', 'Disabled') -IfPresent
        }
    }

    Effect (Param Effect)
}

Source: policyDefinitions/Container Registry/container-registries-enable-zone-redundancy/azurepolicy.json in Azure/Community-Policy, under the MIT licence.