Bylaw

Gallery › Security Center › Azure built-in policies

Configure supported Windows virtual machine scale sets to automatically install the Guest Attestation extension

Converted Policy DeployIfNotExists Disabled Mode Indexed Version 4.2.0

Configure supported Windows virtual machines scale sets to automatically install the Guest Attestation extension to allow Azure Security Center to proactively attest and monitor the boot integrity. Boot integrity is attested via Remote Attestation.

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

Azure Policy JSONASC_InstallWindowsGAExtOnVmss_DINE.json · 162 lines
{
  "properties": {
    "displayName": "Configure supported Windows virtual machine scale sets to automatically install the Guest Attestation extension",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "Configure supported Windows virtual machines scale sets to automatically install the Guest Attestation extension to allow Azure Security Center to proactively attest and monitor the boot integrity. Boot integrity is attested via Remote Attestation.",
    "metadata": {
      "category": "Security Center",
      "version": "4.2.0"
    },
    "version": "4.2.0",
    "parameters": {
      "effect": {
        "type": "string",
        "defaultValue": "DeployIfNotExists",
        "allowedValues": [
          "DeployIfNotExists",
          "Disabled"
        ],
        "metadata": {
          "displayName": "Effect",
          "description": "Enable or disable the execution of the policy"
        }
      },
      "attestationEndpoint": {
        "defaultValue": "",
        "type": "string",
        "metadata": {
          "displayName": "Guest attestation tenant URL",
          "description": "The Microsoft Azure Attestation (MAA) custom tenant URL."
        }
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.Compute/virtualMachineScaleSets"
          },
          {
            "field": "Microsoft.Compute/virtualMachineScaleSets/virtualMachineProfile.storageProfile.imageReference.offer",
            "like": "windows*"
          },
          {
            "field": "Microsoft.Compute/virtualMachineScaleSets/virtualMachineProfile.securityProfile.securityType",
            "in": [
              "TrustedLaunch",
              "ConfidentialVM"
            ]
          },
          {
            "field": "Microsoft.Compute/virtualMachineScaleSets/virtualMachineProfile.securityProfile.uefiSettings",
            "exists": "true"
          },
          {
            "field": "Microsoft.Compute/virtualMachineScaleSets/virtualMachineProfile.securityProfile.uefiSettings.vTpmEnabled",
            "equals": "true"
          },
          {
            "field": "Microsoft.Compute/virtualMachineScaleSets/virtualMachineProfile.securityProfile.uefiSettings.secureBootEnabled",
            "equals": "true"
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]",
        "details": {
          "type": "Microsoft.Compute/virtualMachineScaleSets/extensions",
          "evaluationDelay": "AfterProvisioningSuccess",
          "existenceCondition": {
            "allOf": [
              {
                "field": "Microsoft.Compute/virtualMachineScaleSets/extensions/publisher",
                "equals": "Microsoft.Azure.Security.WindowsAttestation"
              },
              {
                "field": "Microsoft.Compute/virtualMachineScaleSets/extensions/type",
                "equals": "GuestAttestation"
              }
            ]
          },
          "roleDefinitionIds": [
            "/providers/microsoft.authorization/roleDefinitions/9980e02c-c2be-4d73-94e8-173b1dc7cf3c"
          ],
          "deployment": {
            "properties": {
              "mode": "incremental",
              "parameters": {
                "vmssName": {
                  "value": "[field('name')]"
                },
                "location": {
                  "value": "[field('location')]"
                },
                "attestationEndpoint": {
                  "value": "[parameters('attestationEndpoint')]"
                }
              },
              "template": {
                "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
                "contentVersion": "1.0.0.0",
                "parameters": {
                  "vmssName": {
                    "type": "string"
                  },
                  "location": {
                    "type": "string"
                  },
                  "attestationEndpoint": {
                    "type": "string"
                  }
                },
                "variables": {
                  "extensionName": "GuestAttestation",
                  "extensionPublisher": "Microsoft.Azure.Security.WindowsAttestation",
                  "extensionVersion": "1.0",
                  "maaTenantName": "GuestAttestation",
                  "ascReportingEndpoint": ""
                },
                "resources": [
                  {
                    "type": "Microsoft.Compute/virtualMachineScaleSets/extensions",
                    "apiVersion": "2019-12-01",
                    "name": "[concat(parameters('vmssName'), '/', variables('extensionName'))]",
                    "location": "[parameters('location')]",
                    "properties": {
                      "publisher": "[variables('extensionPublisher')]",
                      "type": "[variables('extensionName')]",
                      "typeHandlerVersion": "[variables('extensionVersion')]",
                      "autoUpgradeMinorVersion": true,
                      "settings": {
                        "AttestationConfig": {
                          "MaaSettings": {
                            "maaEndpoint": "[parameters('attestationEndpoint')]",
                            "maaTenantName": "[variables('maaTenantName')]"
                          },
                          "AscSettings": {
                            "ascReportingEndpoint": "[variables('ascReportingEndpoint')]",
                            "ascReportingFrequency": ""
                          },
                          "useCustomToken": "false",
                          "disableAlerts": "false"
                        }
                      }
                    }
                  }
                ]
              }
            }
          }
        }
      }
    },
    "versions": [
      "4.2.0",
      "4.1.0-PREVIEW"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/c9b2ae08-09e2-4f0e-bb43-b60bf0135bdf",
  "name": "c9b2ae08-09e2-4f0e-bb43-b60bf0135bdf"
}
Bylawc9b2ae08-09e2-4f0e-bb43-b60bf0135bdf.bylaw.ps1 · 52 lines
# Converted from ASC_InstallWindowsGAExtOnVmss_DINE.json by ConvertTo-Bylaw.
Policy 'c9b2ae08-09e2-4f0e-bb43-b60bf0135bdf' {

    Properties @{
        DisplayName   = 'Configure supported Windows virtual machine scale sets to automatically install the Guest Attestation extension'
        Description   = 'Configure supported Windows virtual machines scale sets to automatically install the Guest Attestation extension to allow Azure Security Center to proactively attest and monitor the boot integrity. Boot integrity is attested via Remote Attestation.'
        Category      = 'Security Center'
        Version       = '4.2.0'
        PolicyVersion = '4.2.0'
        Mode          = 'Indexed'
    }

    Parameter Effect @{
        Type          = 'string'
        AllowedValues = @('DeployIfNotExists', 'Disabled')
        Default       = 'DeployIfNotExists'
        DisplayName   = 'Effect'
        Description   = 'Enable or disable the execution of the policy'
    }
    Parameter AttestationEndpoint @{
        Type        = 'string'
        Default     = ''
        DisplayName = 'Guest attestation tenant URL'
        Description = 'The Microsoft Azure Attestation (MAA) custom tenant URL.'
    }

    Resource 'Microsoft.Compute/virtualMachineScaleSets' {

        When {
            Field virtualMachineProfile.storageProfile.imageReference.offer | Must -BeLike 'windows*'
            Field virtualMachineProfile.securityProfile.securityType | Must -BeIn @('TrustedLaunch', 'ConfidentialVM')
            Field virtualMachineProfile.securityProfile.uefiSettings | Must -Exist
            Field virtualMachineProfile.securityProfile.uefiSettings.vTpmEnabled | Must -Be 'true'
        }

        Require 'virtualMachineProfile.securityProfile.uefiSettings.secureBootEnabled is not true' {
            Field virtualMachineProfile.securityProfile.uefiSettings.secureBootEnabled | Must -Not -Be 'true' -IfPresent
        }
    }

    DeployIfNotExists 'Microsoft.Compute/virtualMachineScaleSets/extensions' -Role 'Virtual Machine Contributor' -EvaluationDelay AfterProvisioningSuccess -Effect (Param Effect) {
        Require 'publisher is Microsoft.Azure.Security.WindowsAttestation and type is GuestAttestation' {
            Field publisher | Must -Be 'Microsoft.Azure.Security.WindowsAttestation'
            Field 'Microsoft.Compute/virtualMachineScaleSets/extensions/type' | Must -Be 'GuestAttestation'
        }
        Deployment -TemplateFile './templates/c9b2ae08-09e2-4f0e-bb43-b60bf0135bdf.json' -Parameters ([ordered]@{
                vmssName            = (Arm '[field(''name'')]')
                location            = (Arm '[field(''location'')]')
                attestationEndpoint = (Param AttestationEndpoint)
            })
    }
}

Its deployment templates are written beside it:

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