Bylaw

Gallery › Storage › Azure built-in policies

Geo-redundant storage should be enabled for Storage Accounts

Converted Policy Audit Disabled Mode Indexed Version 1.0.0

Use geo-redundancy to create highly available applications

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

Azure Policy JSONGeoRedundant_StorageAccounts_Audit.json · 56 lines
{
  "properties": {
    "displayName": "Geo-redundant storage should be enabled for Storage Accounts",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "Use geo-redundancy to create highly available applications",
    "metadata": {
      "version": "1.0.0",
      "category": "Storage"
    },
    "version": "1.0.0",
    "parameters": {
      "effect": {
        "type": "string",
        "defaultValue": "Audit",
        "allowedValues": [
          "Audit",
          "Disabled"
        ],
        "metadata": {
          "displayName": "Effect",
          "description": "Enable or disable the execution of the policy"
        }
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.Storage/storageAccounts"
          },
          {
            "not": {
              "field": "Microsoft.Storage/storageAccounts/sku.name",
              "in": [
                "Standard_GRS",
                "Standard_RAGRS",
                "Standard_GZRS",
                "Standard_RAGZRS"
              ]
            }
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "versions": [
      "1.0.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/bf045164-79ba-4215-8f95-f8048dc1780b",
  "name": "bf045164-79ba-4215-8f95-f8048dc1780b"
}
Bylawbf045164-79ba-4215-8f95-f8048dc1780b.bylaw.ps1 · 29 lines
# Converted from GeoRedundant_StorageAccounts_Audit.json by ConvertTo-Bylaw.
Policy 'bf045164-79ba-4215-8f95-f8048dc1780b' {

    Properties @{
        DisplayName   = 'Geo-redundant storage should be enabled for Storage Accounts'
        Description   = 'Use geo-redundancy to create highly available applications'
        Version       = '1.0.0'
        Category      = 'Storage'
        PolicyVersion = '1.0.0'
        Mode          = 'Indexed'
    }

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

    Resource 'Microsoft.Storage/storageAccounts' {

        Require 'sku.name is one of 4 values' {
            Field sku.name | Must -BeIn @('Standard_GRS', 'Standard_RAGRS', 'Standard_GZRS', 'Standard_RAGZRS')
        }
    }

    Effect (Param Effect)
}

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