Bylaw

Gallery › SQL › Azure Community Policy

SQL databases should be zone redundant

Converted Policy Audit Disabled Mode All Version 1.0.0

Audit if SQL databases are not configured to be zone redundant

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

Azure Policy JSONazurepolicy.json · 48 lines
{
  "name": "a750f8d8-8c28-4e73-af41-0dae695fb694",
  "type": "Microsoft.Authorization/policyDefinitions",
  "properties": {
    "displayName": "SQL databases should be zone redundant",
    "description": "Audit if SQL databases are not configured to be zone redundant",
    "metadata": {
      "category": "SQL",
      "version": "1.0.0"
    },
    "mode": "All",
    "parameters": {
      "effect": {
        "type": "String",
        "metadata": {
          "displayName": "Effect",
          "description": "Audit or Disabled the execution of the Policy"
        },
        "allowedValues": [
          "Audit",
          "Disabled"
        ],
        "defaultValue": "Audit"
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.SQL/servers/databases"
          },
          {
            "field": "name",
            "notEquals": "master"
          },
          {
            "field": "Microsoft.Sql/servers/databases/zoneRedundant",
            "notEquals": "true"
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    }
  }
}
Bylawa750f8d8-8c28-4e73-af41-0dae695fb694.bylaw.ps1 · 31 lines
# Converted from azurepolicy.json by ConvertTo-Bylaw.
Policy 'a750f8d8-8c28-4e73-af41-0dae695fb694' {

    Properties @{
        DisplayName = 'SQL databases should be zone redundant'
        Description = 'Audit if SQL databases are not configured to be zone redundant'
        Category    = 'SQL'
        Version     = '1.0.0'
        Mode        = 'All'
    }

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

    Resource 'Microsoft.SQL/servers/databases' {

        When {
            Field name | Must -Not -Be 'master'
        }

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

    Effect (Param Effect)
}

Source: policyDefinitions/SQL/sql-databases-should-be-zone-redundant/azurepolicy.json in Azure/Community-Policy, under the MIT licence.