Bylaw

Gallery › Cognitive Services › Azure built-in policies

[Deprecated]: Cognitive Services accounts should use customer owned storage or enable data encryption.

Converted Policy Audit Deny Disabled Mode Indexed Version 2.0.0-deprecated Deprecated

This policy is deprecated. Cognitive Services have data encryption enforced.

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

Azure Policy JSONBYOX_Audit.json · 61 lines
{
  "properties": {
    "displayName": "[Deprecated]: Cognitive Services accounts should use customer owned storage or enable data encryption.",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "This policy is deprecated. Cognitive Services have data encryption enforced.",
    "metadata": {
      "version": "2.0.0-deprecated",
      "category": "Cognitive Services",
      "deprecated": true
    },
    "version": "2.0.0",
    "parameters": {
      "effect": {
        "type": "string",
        "defaultValue": "Disabled",
        "allowedValues": [
          "Audit",
          "Deny",
          "Disabled"
        ],
        "metadata": {
          "displayName": "Effect",
          "description": "The effect determines what happens when the policy rule is evaluated to match"
        }
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.CognitiveServices/accounts"
          },
          {
            "count": {
              "field": "Microsoft.CognitiveServices/accounts/userOwnedStorage[*]"
            },
            "less": 1
          },
          {
            "field": "Microsoft.CognitiveServices/accounts/encryption.keySource",
            "exists": "false"
          },
          {
            "field": "Microsoft.CognitiveServices/accounts/encryption",
            "exists": "true"
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "versions": [
      "2.0.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/11566b39-f7f7-4b82-ab06-68d8700eb0a4",
  "name": "11566b39-f7f7-4b82-ab06-68d8700eb0a4"
}
Bylaw11566b39-f7f7-4b82-ab06-68d8700eb0a4.bylaw.ps1 · 35 lines
# Converted from BYOX_Audit.json by ConvertTo-Bylaw.
Policy '11566b39-f7f7-4b82-ab06-68d8700eb0a4' {

    Properties @{
        DisplayName   = '[Deprecated]: Cognitive Services accounts should use customer owned storage or enable data encryption.'
        Description   = 'This policy is deprecated. Cognitive Services have data encryption enforced.'
        Version       = '2.0.0-deprecated'
        Category      = 'Cognitive Services'
        Deprecated    = $true
        PolicyVersion = '2.0.0'
        Mode          = 'Indexed'
    }

    Parameter Effect @{
        Type          = 'string'
        AllowedValues = @('Audit', 'Deny', 'Disabled')
        Default       = 'Disabled'
        DisplayName   = 'Effect'
        Description   = 'The effect determines what happens when the policy rule is evaluated to match'
    }

    Resource 'Microsoft.CognitiveServices/accounts' {

        When {
            Count 'userOwnedStorage[*]' | Must -Be 0
            Field encryption.keySource | Must -Not -Exist
        }

        Require 'encryption does not exist' {
            Field encryption | Must -Not -Exist
        }
    }

    Effect (Param Effect)
}

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