Bylaw

Gallery › Security Center › Azure built-in policies

vTPM should be enabled on supported virtual machines

Converted Policy Audit Disabled Mode Indexed Version 2.0.1

Enable virtual TPM device on supported virtual machines to facilitate Measured Boot and other OS security features that require a TPM. Once enabled, vTPM can be used to attest boot integrity. This assessment only applies to trusted launch enabled virtual machines.

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

Azure Policy JSONASC_EnableVTPM_Audit.json · 58 lines
{
  "properties": {
    "displayName": "vTPM should be enabled on supported virtual machines",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "Enable virtual TPM device on supported virtual machines to facilitate Measured Boot and other OS security features that require a TPM. Once enabled, vTPM can be used to attest boot integrity. This assessment only applies to trusted launch enabled virtual machines.",
    "metadata": {
      "category": "Security Center",
      "version": "2.0.1"
    },
    "version": "2.0.1",
    "parameters": {
      "effect": {
        "type": "string",
        "defaultValue": "Audit",
        "allowedValues": [
          "Audit",
          "Disabled"
        ],
        "metadata": {
          "displayName": "Effect",
          "description": "Enable or disable the execution of the policy"
        }
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.Compute/virtualMachines"
          },
          {
            "field": "Microsoft.Compute/virtualMachines/securityProfile.securityType",
            "equals": "TrustedLaunch"
          },
          {
            "field": "Microsoft.Compute/virtualMachines/securityProfile.uefiSettings",
            "exists": "true"
          },
          {
            "field": "Microsoft.Compute/virtualMachines/securityProfile.uefiSettings.vTpmEnabled",
            "notequals": "true"
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]"
      }
    },
    "versions": [
      "2.0.1",
      "2.0.0-PREVIEW"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/1c30f9cd-b84c-49cc-aa2c-9288447cc3b3",
  "name": "1c30f9cd-b84c-49cc-aa2c-9288447cc3b3"
}
Bylaw1c30f9cd-b84c-49cc-aa2c-9288447cc3b3.bylaw.ps1 · 34 lines
# Converted from ASC_EnableVTPM_Audit.json by ConvertTo-Bylaw.
Policy '1c30f9cd-b84c-49cc-aa2c-9288447cc3b3' {

    Properties @{
        DisplayName   = 'vTPM should be enabled on supported virtual machines'
        Description   = 'Enable virtual TPM device on supported virtual machines to facilitate Measured Boot and other OS security features that require a TPM. Once enabled, vTPM can be used to attest boot integrity. This assessment only applies to trusted launch enabled virtual machines.'
        Category      = 'Security Center'
        Version       = '2.0.1'
        PolicyVersion = '2.0.1'
        Mode          = 'Indexed'
    }

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

    Resource 'Microsoft.Compute/virtualMachines' {

        When {
            Field securityProfile.securityType | Must -Be 'TrustedLaunch'
            Field securityProfile.uefiSettings | Must -Exist
        }

        Require 'securityProfile.uefiSettings.vTpmEnabled is true' {
            Field securityProfile.uefiSettings.vTpmEnabled | Must -Be 'true'
        }
    }

    Effect (Param Effect)
}

Source: built-in-policies/policyDefinitions/Security Center/ASC_EnableVTPM_Audit.json in Azure/azure-policy, under the MIT licence.