Bylaw

Gallery › App Configuration › Azure built-in policies

App Configuration should use geo-replication

Converted Policy AuditIfNotExists Disabled Mode Indexed Version 1.0.0

Use the geo-replication feature to create replicas in other locations of your current configuration store for enhanced resiliency and availability. Additionally, having multi-region replicas lets you better distribute load, lower latency, protect against datacenter outages, and compartmentalize globally distributed workloads. Learn more at: https://aka.ms/appconfig/geo-replication.

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

Azure Policy JSONGeoReplication_AINE.json · 48 lines
{
  "properties": {
    "displayName": "App Configuration should use geo-replication",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "Use the geo-replication feature to create replicas in other locations of your current configuration store for enhanced resiliency and availability. Additionally, having multi-region replicas lets you better distribute load, lower latency, protect against datacenter outages, and compartmentalize globally distributed workloads. Learn more at: https://aka.ms/appconfig/geo-replication.",
    "metadata": {
      "version": "1.0.0",
      "category": "App Configuration"
    },
    "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.AppConfiguration/configurationStores"
      },
      "then": {
        "effect": "[parameters('effect')]",
        "details": {
          "type": "Microsoft.AppConfiguration/configurationStores/replicas",
          "existenceCondition": {
            "field": "Microsoft.AppConfiguration/configurationStores/replicas/provisioningState",
            "equals": "Succeeded"
          }
        }
      }
    },
    "versions": [
      "1.0.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/d242c24b-bac7-439e-8af7-22d7dcfd3c4f",
  "name": "d242c24b-bac7-439e-8af7-22d7dcfd3c4f"
}
Bylawd242c24b-bac7-439e-8af7-22d7dcfd3c4f.bylaw.ps1 · 27 lines
# Converted from GeoReplication_AINE.json by ConvertTo-Bylaw.
Policy 'd242c24b-bac7-439e-8af7-22d7dcfd3c4f' {

    Properties @{
        DisplayName   = 'App Configuration should use geo-replication'
        Description   = 'Use the geo-replication feature to create replicas in other locations of your current configuration store for enhanced resiliency and availability. Additionally, having multi-region replicas lets you better distribute load, lower latency, protect against datacenter outages, and compartmentalize globally distributed workloads. Learn more at: https://aka.ms/appconfig/geo-replication.'
        Version       = '1.0.0'
        Category      = 'App Configuration'
        PolicyVersion = '1.0.0'
        Mode          = 'Indexed'
    }

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

    Resource 'Microsoft.AppConfiguration/configurationStores'

    AuditIfNotExists 'Microsoft.AppConfiguration/configurationStores/replicas' -Effect (Param Effect) {
        Require 'provisioningState is Succeeded' {
            Field provisioningState | Must -Be 'Succeeded'
        }
    }
}

Source: built-in-policies/policyDefinitions/App Configuration/GeoReplication_AINE.json in Azure/azure-policy, under the MIT licence.