Bylaw

Gallery › Key Vault › Azure Community Policy

Key Vault - SKU Setting AUDIT

Converted Policy Audit Disabled Mode All Version 1.0.0

This Azure Policy creates an audit event when the 'SKU' setting is not included in the 'allowedSKUSetting' parameter.

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

Azure Policy JSONazurepolicy.json · 52 lines
{
  "name": "85c3251e-8f6d-44d1-984a-24f7ec77b79e",
  "type": "Microsoft.Authorization/policyDefinitions",
  "properties": {
    "displayName": "Key Vault - SKU Setting AUDIT",
    "description": "This Azure Policy creates an audit event when the 'SKU' setting is not included in the 'allowedSKUSetting' parameter.",
    "metadata": {
      "version": "1.0.0",
      "category": "Key Vault"
    },
    "mode": "All",
    "parameters": {
      "allowedSKUSetting": {
        "type": "String",
        "metadata": {
          "displayName": "Allowed SKU Setting",
          "description": "The allowed SKU setting of an Azure Key Vault"
        },
        "defaultValue": "Premium"
      },
      "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.KeyVault/vaults"
          },
          {
            "field": "Microsoft.KeyVault/vaults/sku.name",
            "notEquals": "[parameters('allowedSKUSetting')]"
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    }
  }
}
Bylaw85c3251e-8f6d-44d1-984a-24f7ec77b79e.bylaw.ps1 · 32 lines
# Converted from azurepolicy.json by ConvertTo-Bylaw.
Policy '85c3251e-8f6d-44d1-984a-24f7ec77b79e' {

    Properties @{
        DisplayName = 'Key Vault - SKU Setting AUDIT'
        Description = 'This Azure Policy creates an audit event when the ''SKU'' setting is not included in the ''allowedSKUSetting'' parameter.'
        Version     = '1.0.0'
        Category    = 'Key Vault'
        Mode        = 'All'
    }

    Parameter AllowedSKUSetting @{
        Default     = 'Premium'
        DisplayName = 'Allowed SKU Setting'
        Description = 'The allowed SKU setting of an Azure Key Vault'
    }
    Parameter Effect @{
        AllowedValues = @('Audit', 'Disabled')
        Default       = 'Audit'
        DisplayName   = 'Effect'
        Description   = 'Audit or Disabled the execution of the Policy'
    }

    Resource 'Microsoft.KeyVault/vaults' {

        Require 'sku.name is the AllowedSKUSetting parameter' {
            Field sku.name | Must -Be (Param AllowedSKUSetting)
        }
    }

    Effect (Param Effect)
}

Source: policyDefinitions/Key Vault/key-vault-sku-setting-audit/azurepolicy.json in Azure/Community-Policy, under the MIT licence.