Bylaw

Gallery › Search › Azure built-in policies

Azure AI Search services should use customer-managed keys to encrypt data at rest

Converted Policy AuditIfNotExists Disabled Mode Indexed Version 2.1.0

Enabling encryption at rest using a customer-managed key on your Azure AI Search services provides additional control over the key used to encrypt data at rest. This feature is often applicable to customers with special compliance requirements to manage data encryption keys using a key vault.

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

Azure Policy JSONCMK_Audit.json · 59 lines
{
  "properties": {
    "displayName": "Azure AI Search services should use customer-managed keys to encrypt data at rest",
    "description": "Enabling encryption at rest using a customer-managed key on your Azure AI Search services provides additional control over the key used to encrypt data at rest. This feature is often applicable to customers with special compliance requirements to manage data encryption keys using a key vault.",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "metadata": {
      "category": "Search",
      "version": "2.1.0"
    },
    "version": "2.1.0",
    "parameters": {
      "effect": {
        "type": "String",
        "metadata": {
          "displayName": "Effect",
          "description": "Enable or disable the execution of the policy"
        },
        "allowedValues": [
          "AuditIfNotExists",
          "Disabled"
        ],
        "defaultValue": "AuditIfNotExists"
      }
    },
    "policyRule": {
      "if": {
        "field": "type",
        "equals": "Microsoft.Search/searchServices"
      },
      "then": {
        "effect": "[parameters('effect')]",
        "details": {
          "type": "Microsoft.Search/searchServices",
          "name": "[field('name')]",
          "existenceCondition": {
            "allOf": [
              {
                "field": "Microsoft.Search/searchServices/encryptionWithCmk.enforcement",
                "equals": "Enabled"
              },
              {
                "field": "Microsoft.Search/searchServices/encryptionWithCmk.encryptionComplianceStatus",
                "equals": "Compliant"
              }
            ]
          }
        }
      }
    },
    "versions": [
      "2.1.0",
      "2.0.0",
      "1.0.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/76a56461-9dc0-40f0-82f5-2453283afa2f",
  "name": "76a56461-9dc0-40f0-82f5-2453283afa2f"
}
Bylaw76a56461-9dc0-40f0-82f5-2453283afa2f.bylaw.ps1 · 28 lines
# Converted from CMK_Audit.json by ConvertTo-Bylaw.
Policy '76a56461-9dc0-40f0-82f5-2453283afa2f' {

    Properties @{
        DisplayName   = 'Azure AI Search services should use customer-managed keys to encrypt data at rest'
        Description   = 'Enabling encryption at rest using a customer-managed key on your Azure AI Search services provides additional control over the key used to encrypt data at rest. This feature is often applicable to customers with special compliance requirements to manage data encryption keys using a key vault.'
        Category      = 'Search'
        Version       = '2.1.0'
        PolicyVersion = '2.1.0'
        Mode          = 'Indexed'
    }

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

    Resource 'Microsoft.Search/searchServices'

    AuditIfNotExists 'Microsoft.Search/searchServices' -Name (Arm '[field(''name'')]') -Effect (Param Effect) {
        Require 'encryptionWithCmk.enforcement and encryptionWithCmk.encryptionComplianceStatus are as required' {
            Field encryptionWithCmk.enforcement | Must -Be 'Enabled'
            Field encryptionWithCmk.encryptionComplianceStatus | Must -Be 'Compliant'
        }
    }
}

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