Bylaw

Gallery › Storage › Azure built-in policies

Queue Storage should use customer-managed key for encryption

Converted Policy Audit Deny Disabled Mode Indexed Version 1.0.0

Secure your queue storage with greater flexibility using customer-managed keys. When you specify a customer-managed key, that key is used to protect and control access to the key that encrypts your data. Using customer-managed keys provides additional capabilities to control rotation of the key encryption key or cryptographically erase data.

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

Azure Policy JSONStorageQueueCustomerManagedKeyEnabled_Audit.json · 54 lines
{
  "properties": {
    "displayName": "Queue Storage should use customer-managed key for encryption",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "Secure your queue storage with greater flexibility using customer-managed keys. When you specify a customer-managed key, that key is used to protect and control access to the key that encrypts your data. Using customer-managed keys provides additional capabilities to control rotation of the key encryption key or cryptographically erase data.",
    "metadata": {
      "version": "1.0.0",
      "category": "Storage"
    },
    "version": "1.0.0",
    "parameters": {
      "effect": {
        "type": "String",
        "metadata": {
          "displayName": "Effect",
          "description": "Enable or disable the execution of the policy"
        },
        "allowedValues": [
          "Audit",
          "Deny",
          "Disabled"
        ],
        "defaultValue": "Audit"
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.Storage/storageAccounts"
          },
          {
            "field": "Microsoft.Storage/storageAccounts/encryption.keySource",
            "equals": "Microsoft.Keyvault"
          },
          {
            "field": "Microsoft.Storage/storageAccounts/encryption.services.queue.keyType",
            "notEquals": "Account"
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "versions": [
      "1.0.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/f0e5abd0-2554-4736-b7c0-4ffef23475ef",
  "name": "f0e5abd0-2554-4736-b7c0-4ffef23475ef"
}
Bylawf0e5abd0-2554-4736-b7c0-4ffef23475ef.bylaw.ps1 · 32 lines
# Converted from StorageQueueCustomerManagedKeyEnabled_Audit.json by ConvertTo-Bylaw.
Policy 'f0e5abd0-2554-4736-b7c0-4ffef23475ef' {

    Properties @{
        DisplayName   = 'Queue Storage should use customer-managed key for encryption'
        Description   = 'Secure your queue storage with greater flexibility using customer-managed keys. When you specify a customer-managed key, that key is used to protect and control access to the key that encrypts your data. Using customer-managed keys provides additional capabilities to control rotation of the key encryption key or cryptographically erase data.'
        Version       = '1.0.0'
        Category      = 'Storage'
        PolicyVersion = '1.0.0'
        Mode          = 'Indexed'
    }

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

    Resource 'Microsoft.Storage/storageAccounts' {

        When {
            Field encryption.keySource | Must -Be 'Microsoft.Keyvault'
        }

        Require 'encryption.services.queue.keyType is Account' {
            Field encryption.services.queue.keyType | Must -Be 'Account'
        }
    }

    Effect (Param Effect)
}

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