Bylaw

Gallery › Storage › Azure Community Policy

Storage Account - Customer Managed Keys Queue and Table Storage AUDIT

Converted Policy Audit Disabled Mode All Version 1.0.0

This Azure Policy creates an audit event when the 'Enable support for customer-managed keys' setting is set to 'Blobs and files only'.

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

Azure Policy JSONazurepolicy.json · 48 lines
{
  "name": "e58e2c3b-2283-4dd5-a033-5c260c8744d2",
  "type": "Microsoft.Authorization/policyDefinitions",
  "properties": {
    "displayName": "Storage Account - Customer Managed Keys Queue and Table Storage AUDIT",
    "description": "This Azure Policy creates an audit event when the 'Enable support for customer-managed keys' setting is set to 'Blobs and files only'.",
    "metadata": {
      "version": "1.0.0",
      "category": "Storage"
    },
    "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.Storage/storageAccounts"
          },
          {
            "field": "Microsoft.Storage/storageAccounts/encryption.services.queue.enabled",
            "exists": "false"
          },
          {
            "field": "Microsoft.Storage/storageAccounts/encryption.services.table.enabled",
            "exists": "false"
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    }
  }
}
Bylawe58e2c3b-2283-4dd5-a033-5c260c8744d2.bylaw.ps1 · 31 lines
# Converted from azurepolicy.json by ConvertTo-Bylaw.
Policy 'e58e2c3b-2283-4dd5-a033-5c260c8744d2' {

    Properties @{
        DisplayName = 'Storage Account - Customer Managed Keys Queue and Table Storage AUDIT'
        Description = 'This Azure Policy creates an audit event when the ''Enable support for customer-managed keys'' setting is set to ''Blobs and files only''.'
        Version     = '1.0.0'
        Category    = 'Storage'
        Mode        = 'All'
    }

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

    Resource 'Microsoft.Storage/storageAccounts' {

        When {
            Field encryption.services.queue.enabled | Must -Not -Exist
        }

        Require 'encryption.services.table.enabled exists' {
            Field encryption.services.table.enabled | Must -Exist
        }
    }

    Effect (Param Effect)
}

Source: policyDefinitions/Storage/storage-account-customer-managed-keys-queue-and-table-storage-audit/azurepolicy.json in Azure/Community-Policy, under the MIT licence.