Bylaw

Gallery › Storage › Azure Community Policy

Audit-Storage-EncryptionWithoutHSM

Converted Policy Audit Disabled Mode All Version 1.0.0

Audit effect will be executed on Storage Accounts in scope, where Storage Account encryption is not configured via CMK from Managed HSM.

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

Azure Policy JSONazurepolicy.json · 52 lines
{
  "name": "61cbe0c0-05d8-4853-8233-9b9e89c8456d",
  "type": "Microsoft.Authorization/policyDefinitions",
  "properties": {
    "displayName": "Audit-Storage-EncryptionWithoutHSM",
    "description": "Audit effect will be executed on Storage Accounts in scope, where Storage Account encryption is not configured via CMK from Managed HSM.",
    "metadata": {
      "category": "Storage",
      "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.Storage/storageAccounts"
          },
          {
            "anyOf": [
              {
                "field": "Microsoft.Storage/storageAccounts/encryption.keySource",
                "notEquals": "Microsoft.KeyVault"
              },
              {
                "field": "Microsoft.Storage/storageAccounts/encryption.keyvaultproperties.keyvaulturi",
                "notLike": "https://*.managedhsm.azure.net/"
              }
            ]
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    }
  }
}
Bylaw61cbe0c0-05d8-4853-8233-9b9e89c8456d.bylaw.ps1 · 31 lines
# Converted from azurepolicy.json by ConvertTo-Bylaw.
Policy '61cbe0c0-05d8-4853-8233-9b9e89c8456d' {

    Properties @{
        DisplayName = 'Audit-Storage-EncryptionWithoutHSM'
        Description = 'Audit effect will be executed on Storage Accounts in scope, where Storage Account encryption is not configured via CMK from Managed HSM.'
        Category    = 'Storage'
        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.Storage/storageAccounts' {

        Require 'encryption.keySource is Microsoft.KeyVault' {
            Field encryption.keySource | Must -Be 'Microsoft.KeyVault'
        }

        Require 'encryption.keyvaultproperties.keyvaulturi is like https://*.managedhsm.azure.net/' {
            Field encryption.keyvaultproperties.keyvaulturi | Must -BeLike 'https://*.managedhsm.azure.net/'
        }
    }

    Effect (Param Effect)
}

Source: policyDefinitions/Storage/audit-storage-encryptionwithouthsm/azurepolicy.json in Azure/Community-Policy, under the MIT licence.