Bylaw

Gallery › Internet of Things › Azure built-in policies

Azure Device Update accounts should use customer-managed key to encrypt data at rest

Converted Policy Audit Deny Disabled Mode Indexed Version 1.0.0

Encryption of data at rest in Azure Device Update with customer-managed key adds a second layer of encryption on top of the default service-managed keys, enables customer control of keys, custom rotation policies, and ability to manage access to data through key access control. Learn more at:https://learn.microsoft.com/azure/iot-hub-device-update/device-update-data-encryption.

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

Azure Policy JSONDeviceUpdate_CMKEnabled_Audit.json · 50 lines
{
  "properties": {
    "displayName": "Azure Device Update accounts should use customer-managed key to encrypt data at rest",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "Encryption of data at rest in Azure Device Update with customer-managed key adds a second layer of encryption on top of the default service-managed keys, enables customer control of keys, custom rotation policies, and ability to manage access to data through key access control. Learn more at:https://learn.microsoft.com/azure/iot-hub-device-update/device-update-data-encryption. ",
    "metadata": {
      "version": "1.0.0",
      "category": "Internet of Things"
    },
    "version": "1.0.0",
    "parameters": {
      "effect": {
        "type": "String",
        "metadata": {
          "displayName": "Effect",
          "description": "The desired effect of the policy."
        },
        "allowedValues": [
          "Audit",
          "Deny",
          "Disabled"
        ],
        "defaultValue": "Audit"
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.DeviceUpdate/accounts"
          },
          {
            "field": "Microsoft.DeviceUpdate/accounts/encryption.keyVaultKeyUri",
            "exists": false
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "versions": [
      "1.0.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/43c323f6-0329-4f7c-a19a-6e5a5690d042",
  "name": "43c323f6-0329-4f7c-a19a-6e5a5690d042"
}
Bylaw43c323f6-0329-4f7c-a19a-6e5a5690d042.bylaw.ps1 · 28 lines
# Converted from DeviceUpdate_CMKEnabled_Audit.json by ConvertTo-Bylaw.
Policy '43c323f6-0329-4f7c-a19a-6e5a5690d042' {

    Properties @{
        DisplayName   = 'Azure Device Update accounts should use customer-managed key to encrypt data at rest'
        Description   = 'Encryption of data at rest in Azure Device Update with customer-managed key adds a second layer of encryption on top of the default service-managed keys, enables customer control of keys, custom rotation policies, and ability to manage access to data through key access control. Learn more at:https://learn.microsoft.com/azure/iot-hub-device-update/device-update-data-encryption. '
        Version       = '1.0.0'
        Category      = 'Internet of Things'
        PolicyVersion = '1.0.0'
        Mode          = 'Indexed'
    }

    Parameter Effect @{
        AllowedValues = @('Audit', 'Deny', 'Disabled')
        Default       = 'Audit'
        DisplayName   = 'Effect'
        Description   = 'The desired effect of the policy.'
    }

    Resource 'Microsoft.DeviceUpdate/accounts' {

        Require 'encryption.keyVaultKeyUri exists' {
            Field encryption.keyVaultKeyUri | Must -Exist
        }
    }

    Effect (Param Effect)
}

Source: built-in-policies/policyDefinitions/Internet of Things/DeviceUpdate_CMKEnabled_Audit.json in Azure/azure-policy, under the MIT licence.