Bylaw

Gallery › Backup › Azure built-in policies

Do not allow creation of Recovery Services vaults of chosen storage redundancy.

Converted Policy Deny Disabled Mode Indexed Version 1.0.1

Recovery Services vaults can be created with any one of three storage redundancy options today, namely, Locally-redundant Storage, Zone-redundant storage and Geo-redundant storage. If the policies in your organization requires you to block the creation of vaults that belong to a certain redundancy type, you may achieve the same using this Azure policy.

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

Azure Policy JSONAzBackuprecoveryServicesVault_RedudancySettings_Deny.json · 63 lines
{
  "properties": {
    "displayName": "Do not allow creation of Recovery Services vaults of chosen storage redundancy.",
    "description": "Recovery Services vaults can be created with any one of three storage redundancy options today, namely, Locally-redundant Storage, Zone-redundant storage and Geo-redundant storage. If the policies in your organization requires you to block the creation of vaults that belong to a certain redundancy type, you may achieve the same using this Azure policy.",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "metadata": {
      "version": "1.0.1",
      "category": "Backup"
    },
    "version": "1.0.1",
    "parameters": {
      "effect": {
        "type": "String",
        "metadata": {
          "displayName": "Effect",
          "description": "Enable or disable the execution of the policy."
        },
        "allowedValues": [
          "Deny",
          "Disabled"
        ],
        "defaultValue": "Deny"
      },
      "BackupStorageRedundancy": {
        "type": "String",
        "metadata": {
          "displayName": "Backup Storage Redundancy",
          "description": "Specify the storage redundancy for which creation of Recovery Services vaults should not be allowed by policy."
        },
        "allowedValues": [
          "GeoRedundant",
          "ZoneRedundant",
          "LocallyRedundant"
        ],
        "defaultValue": "GeoRedundant"
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.RecoveryServices/vaults"
          },
          {
            "field": "Microsoft.RecoveryServices/vaults/redundancySettings.standardTierStorageRedundancy",
            "equals": "[parameters('BackupStorageRedundancy')]"
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "versions": [
      "1.0.1",
      "1.0.0-PREVIEW"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/8f09fda1-91a2-4e14-96a2-67c6281158f7",
  "name": "8f09fda1-91a2-4e14-96a2-67c6281158f7"
}
Bylaw8f09fda1-91a2-4e14-96a2-67c6281158f7.bylaw.ps1 · 35 lines
# Converted from AzBackuprecoveryServicesVault_RedudancySettings_Deny.json by ConvertTo-Bylaw.
Policy '8f09fda1-91a2-4e14-96a2-67c6281158f7' {

    Properties @{
        DisplayName   = 'Do not allow creation of Recovery Services vaults of chosen storage redundancy.'
        Description   = 'Recovery Services vaults can be created with any one of three storage redundancy options today, namely, Locally-redundant Storage, Zone-redundant storage and Geo-redundant storage. If the policies in your organization requires you to block the creation of vaults that belong to a certain redundancy type, you may achieve the same using this Azure policy.'
        Version       = '1.0.1'
        Category      = 'Backup'
        PolicyVersion = '1.0.1'
        Mode          = 'Indexed'
    }

    Parameter Effect @{
        AllowedValues = @('Deny', 'Disabled')
        Default       = 'Deny'
        DisplayName   = 'Effect'
        Description   = 'Enable or disable the execution of the policy.'
    }
    Parameter BackupStorageRedundancy @{
        AllowedValues = @('GeoRedundant', 'ZoneRedundant', 'LocallyRedundant')
        Default       = 'GeoRedundant'
        DisplayName   = 'Backup Storage Redundancy'
        Description   = 'Specify the storage redundancy for which creation of Recovery Services vaults should not be allowed by policy.'
        JsonName      = 'BackupStorageRedundancy'
    }

    Resource 'Microsoft.RecoveryServices/vaults' {

        Require 'redundancySettings.standardTierStorageRedundancy is not the BackupStorageRedundancy parameter' {
            Field redundancySettings.standardTierStorageRedundancy | Must -Not -Be (Param BackupStorageRedundancy) -IfPresent
        }
    }

    Effect (Param Effect)
}

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