Bylaw

Gallery › Cognitive Services › Azure built-in policies

Azure AI Services resources should encrypt data at rest with a customer-managed key (CMK)

Converted Policy Audit Deny Disabled Mode Indexed Version 2.2.0

Using customer-managed keys to encrypt data at rest provides more control over the key lifecycle, including rotation and management. This is particularly relevant for organizations with related compliance requirements. This is not assessed by default and should only be applied when required by compliance or restrictive policy requirements. If not enabled, the data will be encrypted using platform-managed keys. To implement this, update the 'Effect' parameter in the Security Policy for the applicable scope.

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

Azure Policy JSONCustomerManagedKey_Audit.json · 80 lines
{
  "properties": {
    "displayName": "Azure AI Services resources should encrypt data at rest with a customer-managed key (CMK)",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "Using customer-managed keys to encrypt data at rest provides more control over the key lifecycle, including rotation and management. This is particularly relevant for organizations with related compliance requirements. This is not assessed by default and should only be applied when required by compliance or restrictive policy requirements. If not enabled, the data will be encrypted using platform-managed keys. To implement this, update the 'Effect' parameter in the Security Policy for the applicable scope.",
    "metadata": {
      "version": "2.2.0",
      "category": "Cognitive Services"
    },
    "version": "2.2.0",
    "parameters": {
      "effect": {
        "type": "string",
        "defaultValue": "Audit",
        "allowedValues": [
          "Audit",
          "Deny",
          "Disabled"
        ],
        "metadata": {
          "displayName": "Effect",
          "description": "The effect determines what happens when the policy rule is evaluated to match"
        }
      },
      "excludedKinds": {
        "type": "Array",
        "metadata": {
          "displayName": "Excluded Kinds",
          "description": "The list of excluded API kinds for customer-managed key, default is the list of API kinds that don't have data stored in Cognitive Services"
        },
        "defaultValue": [
          "CognitiveServices",
          "ContentSafety",
          "ImmersiveReader",
          "HealthInsights",
          "LUIS.Authoring",
          "LUIS",
          "QnAMaker",
          "QnAMaker.V2",
          "AIServices",
          "MetricsAdvisor",
          "SpeechTranslation",
          "Internal.AllInOne",
          "ConversationalLanguageUnderstanding",
          "knowledge",
          "TranscriptionIntelligence",
          "HealthDecisionSupport"
        ]
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.CognitiveServices/accounts"
          },
          {
            "field": "Microsoft.CognitiveServices/accounts/encryption.keySource",
            "notEquals": "Microsoft.KeyVault"
          },
          {
            "field": "kind",
            "notIn": "[parameters('excludedKinds')]"
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "versions": [
      "2.2.0",
      "2.1.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/67121cc7-ff39-4ab8-b7e3-95b84dab487d",
  "name": "67121cc7-ff39-4ab8-b7e3-95b84dab487d"
}
Bylaw67121cc7-ff39-4ab8-b7e3-95b84dab487d.bylaw.ps1 · 39 lines
# Converted from CustomerManagedKey_Audit.json by ConvertTo-Bylaw.
Policy '67121cc7-ff39-4ab8-b7e3-95b84dab487d' {

    Properties @{
        DisplayName   = 'Azure AI Services resources should encrypt data at rest with a customer-managed key (CMK)'
        Description   = 'Using customer-managed keys to encrypt data at rest provides more control over the key lifecycle, including rotation and management. This is particularly relevant for organizations with related compliance requirements. This is not assessed by default and should only be applied when required by compliance or restrictive policy requirements. If not enabled, the data will be encrypted using platform-managed keys. To implement this, update the ''Effect'' parameter in the Security Policy for the applicable scope.'
        Version       = '2.2.0'
        Category      = 'Cognitive Services'
        PolicyVersion = '2.2.0'
        Mode          = 'Indexed'
    }

    Parameter Effect @{
        Type          = 'string'
        AllowedValues = @('Audit', 'Deny', 'Disabled')
        Default       = 'Audit'
        DisplayName   = 'Effect'
        Description   = 'The effect determines what happens when the policy rule is evaluated to match'
    }
    Parameter ExcludedKinds @{
        Type        = 'Array'
        Default     = @('CognitiveServices', 'ContentSafety', 'ImmersiveReader', 'HealthInsights', 'LUIS.Authoring', 'LUIS', 'QnAMaker', 'QnAMaker.V2', 'AIServices', 'MetricsAdvisor', 'SpeechTranslation', 'Internal.AllInOne', 'ConversationalLanguageUnderstanding', 'knowledge', 'TranscriptionIntelligence', 'HealthDecisionSupport')
        DisplayName = 'Excluded Kinds'
        Description = 'The list of excluded API kinds for customer-managed key, default is the list of API kinds that don''t have data stored in Cognitive Services'
    }

    Resource 'Microsoft.CognitiveServices/accounts' {

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

        Require 'kind is one of the ExcludedKinds parameter' {
            Field kind | Must -BeIn (Param ExcludedKinds)
        }
    }

    Effect (Param Effect)
}

Source: built-in-policies/policyDefinitions/Cognitive Services/CustomerManagedKey_Audit.json in Azure/azure-policy, under the MIT licence.