Bylaw

Gallery › Security Center › Azure built-in policies

Configure ChangeTracking Extension for Windows virtual machines

Converted Policy DeployIfNotExists Disabled Mode Indexed Version 2.2.0

Configure Windows virtual machines to automatically install the ChangeTracking Extension to enable File Integrity Monitoring(FIM) in Azure Security Center. FIM examines operating system files, Windows registries, application software, Linux system files, and more, for changes that might indicate an attack. The extension can be installed in virtual machines and locations supported by Azure Monitor Agent.

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

Azure Policy JSONASC_ChangeTrackingWindowsAgent_DINE.json · 477 lines
{
  "properties": {
    "displayName": "Configure ChangeTracking Extension for Windows virtual machines",
    "description": "Configure Windows virtual machines to automatically install the ChangeTracking Extension to enable File Integrity Monitoring(FIM) in Azure Security Center. FIM examines operating system files, Windows registries, application software, Linux system files, and more, for changes that might indicate an attack. The extension can be installed in virtual machines and locations supported by Azure Monitor Agent.",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "metadata": {
      "version": "2.2.0",
      "category": "Security Center"
    },
    "version": "2.2.0",
    "parameters": {
      "effect": {
        "type": "String",
        "metadata": {
          "displayName": "Effect",
          "description": "Enable or disable the execution of the policy"
        },
        "defaultValue": "DeployIfNotExists",
        "allowedValues": [
          "DeployIfNotExists",
          "Disabled"
        ]
      },
      "listOfApplicableLocations": {
        "type": "Array",
        "metadata": {
          "displayName": "Applicable Locations",
          "description": "The list of locations where the policy should be applied.",
          "strongType": "location"
        },
        "allowedValues": [
          "australiacentral",
          "australiacentral2",
          "australiaeast",
          "australiasoutheast",
          "brazilsouth",
          "brazilsoutheast",
          "canadacentral",
          "canadaeast",
          "centralindia",
          "centralus",
          "centraluseuap",
          "eastasia",
          "eastus",
          "eastus2",
          "eastus2euap",
          "francecentral",
          "francesouth",
          "germanynorth",
          "germanywestcentral",
          "israelcentral",
          "italynorth",
          "japaneast",
          "japanwest",
          "jioindiacentral",
          "jioindiawest",
          "koreacentral",
          "koreasouth",
          "malaysiasouth",
          "mexicocentral",
          "northcentralus",
          "northeurope",
          "norwayeast",
          "norwaywest",
          "polandcentral",
          "qatarcentral",
          "southafricanorth",
          "southafricawest",
          "southcentralus",
          "southeastasia",
          "southindia",
          "spaincentral",
          "swedencentral",
          "swedensouth",
          "switzerlandnorth",
          "switzerlandwest",
          "taiwannorth",
          "taiwannorthwest",
          "uaecentral",
          "uaenorth",
          "uksouth",
          "ukwest",
          "westcentralus",
          "westeurope",
          "westindia",
          "westus",
          "westus2",
          "westus3"
        ],
        "defaultValue": [
          "australiacentral",
          "australiacentral2",
          "australiaeast",
          "australiasoutheast",
          "brazilsouth",
          "brazilsoutheast",
          "canadacentral",
          "canadaeast",
          "centralindia",
          "centralus",
          "centraluseuap",
          "eastasia",
          "eastus",
          "eastus2",
          "eastus2euap",
          "francecentral",
          "francesouth",
          "germanynorth",
          "germanywestcentral",
          "israelcentral",
          "italynorth",
          "japaneast",
          "japanwest",
          "jioindiacentral",
          "jioindiawest",
          "koreacentral",
          "koreasouth",
          "malaysiasouth",
          "mexicocentral",
          "northcentralus",
          "northeurope",
          "norwayeast",
          "norwaywest",
          "polandcentral",
          "qatarcentral",
          "southafricanorth",
          "southafricawest",
          "southcentralus",
          "southeastasia",
          "southindia",
          "spaincentral",
          "swedencentral",
          "swedensouth",
          "switzerlandnorth",
          "switzerlandwest",
          "taiwannorth",
          "taiwannorthwest",
          "uaecentral",
          "uaenorth",
          "uksouth",
          "ukwest",
          "westcentralus",
          "westeurope",
          "westindia",
          "westus",
          "westus2",
          "westus3"
        ]
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.Compute/virtualMachines"
          },
          {
            "field": "location",
            "in": "[parameters('listOfApplicableLocations')]"
          },
          {
            "anyOf": [
              {
                "allOf": [
                  {
                    "field": "Microsoft.Compute/virtualMachines/storageProfile.osDisk.osType",
                    "like": "Windows*"
                  },
                  {
                    "anyOf": [
                      {
                        "field": "Microsoft.Compute/imageId",
                        "contains": "Microsoft.Compute/galleries"
                      },
                      {
                        "field": "Microsoft.Compute/imageId",
                        "contains": "Microsoft.Compute/images"
                      },
                      {
                        "field": "Microsoft.Compute/virtualMachines/storageProfile.osDisk.createOption",
                        "equals": "Attach"
                      }
                    ]
                  }
                ]
              },
              {
                "allOf": [
                  {
                    "field": "Microsoft.Compute/imagePublisher",
                    "equals": "MicrosoftWindowsServer"
                  },
                  {
                    "field": "Microsoft.Compute/imageOffer",
                    "equals": "WindowsServer"
                  },
                  {
                    "anyOf": [
                      {
                        "field": "Microsoft.Compute/imageSku",
                        "like": "2008-R2-SP1*"
                      },
                      {
                        "field": "Microsoft.Compute/imageSku",
                        "like": "2012-*"
                      },
                      {
                        "field": "Microsoft.Compute/imageSku",
                        "like": "2016-*"
                      },
                      {
                        "field": "Microsoft.Compute/imageSku",
                        "like": "2019-*"
                      },
                      {
                        "field": "Microsoft.Compute/imageSku",
                        "like": "2022-*"
                      },
                      {
                        "field": "Microsoft.Compute/imageSku",
                        "like": "2025-*"
                      }
                    ]
                  }
                ]
              },
              {
                "allOf": [
                  {
                    "field": "Microsoft.Compute/imagePublisher",
                    "equals": "MicrosoftWindowsServer"
                  },
                  {
                    "field": "Microsoft.Compute/imageOffer",
                    "equals": "WindowsServerSemiAnnual"
                  },
                  {
                    "field": "Microsoft.Compute/imageSKU",
                    "in": [
                      "Datacenter-Core-1709-smalldisk",
                      "Datacenter-Core-1709-with-Containers-smalldisk",
                      "Datacenter-Core-1803-with-Containers-smalldisk"
                    ]
                  }
                ]
              },
              {
                "allOf": [
                  {
                    "field": "Microsoft.Compute/imagePublisher",
                    "equals": "MicrosoftWindowsServerHPCPack"
                  },
                  {
                    "field": "Microsoft.Compute/imageOffer",
                    "equals": "WindowsServerHPCPack"
                  }
                ]
              },
              {
                "allOf": [
                  {
                    "field": "Microsoft.Compute/imagePublisher",
                    "equals": "MicrosoftSQLServer"
                  },
                  {
                    "anyOf": [
                      {
                        "field": "Microsoft.Compute/imageOffer",
                        "like": "*-WS2022"
                      },
                      {
                        "field": "Microsoft.Compute/imageOffer",
                        "like": "*-WS2022-BYOL"
                      },
                      {
                        "field": "Microsoft.Compute/imageOffer",
                        "like": "*-WS2019"
                      },
                      {
                        "field": "Microsoft.Compute/imageOffer",
                        "like": "*-WS2019-BYOL"
                      },
                      {
                        "field": "Microsoft.Compute/imageOffer",
                        "like": "*-WS2016"
                      },
                      {
                        "field": "Microsoft.Compute/imageOffer",
                        "like": "*-WS2016-BYOL"
                      },
                      {
                        "field": "Microsoft.Compute/imageOffer",
                        "like": "*-WS2012R2"
                      },
                      {
                        "field": "Microsoft.Compute/imageOffer",
                        "like": "*-WS2012R2-BYOL"
                      }
                    ]
                  }
                ]
              },
              {
                "allOf": [
                  {
                    "field": "Microsoft.Compute/imagePublisher",
                    "equals": "MicrosoftRServer"
                  },
                  {
                    "field": "Microsoft.Compute/imageOffer",
                    "equals": "MLServer-WS2016"
                  }
                ]
              },
              {
                "allOf": [
                  {
                    "field": "Microsoft.Compute/imagePublisher",
                    "equals": "MicrosoftVisualStudio"
                  },
                  {
                    "field": "Microsoft.Compute/imageOffer",
                    "in": [
                      "VisualStudio",
                      "Windows"
                    ]
                  }
                ]
              },
              {
                "allOf": [
                  {
                    "field": "Microsoft.Compute/imagePublisher",
                    "equals": "MicrosoftDynamicsAX"
                  },
                  {
                    "field": "Microsoft.Compute/imageOffer",
                    "equals": "Dynamics"
                  },
                  {
                    "field": "Microsoft.Compute/imageSKU",
                    "equals": "Pre-Req-AX7-Onebox-U8"
                  }
                ]
              },
              {
                "allOf": [
                  {
                    "field": "Microsoft.Compute/imagePublisher",
                    "equals": "microsoft-ads"
                  },
                  {
                    "field": "Microsoft.Compute/imageOffer",
                    "equals": "windows-data-science-vm"
                  }
                ]
              },
              {
                "allOf": [
                  {
                    "field": "Microsoft.Compute/imagePublisher",
                    "equals": "MicrosoftWindowsDesktop"
                  },
                  {
                    "field": "Microsoft.Compute/imageOffer",
                    "in": [
                      "Windows-10",
                      "Windows-11"
                    ]
                  }
                ]
              },
              {
                "allOf": [
                  {
                    "field": "Microsoft.Compute/imagePublisher",
                    "equals": "center-for-internet-security-inc"
                  },
                  {
                    "field": "Microsoft.Compute/imageOffer",
                    "equals": "cis-windows-server"
                  },
                  {
                    "field": "Microsoft.Compute/imageSKU",
                    "equals": "cis-windows-server2022-l1-gen1"
                  }
                ]
              }
            ]
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]",
        "details": {
          "type": "Microsoft.Compute/virtualMachines/extensions",
          "roleDefinitionIds": [
            "/providers/microsoft.authorization/roleDefinitions/9980e02c-c2be-4d73-94e8-173b1dc7cf3c"
          ],
          "existenceCondition": {
            "allOf": [
              {
                "field": "Microsoft.Compute/virtualMachines/extensions/type",
                "equals": "ChangeTracking-Windows"
              },
              {
                "field": "Microsoft.Compute/virtualMachines/extensions/Publisher",
                "equals": "Microsoft.Azure.ChangeTrackingAndInventory"
              },
              {
                "field": "Microsoft.Compute/virtualMachines/extensions/provisioningState",
                "equals": "Succeeded"
              }
            ]
          },
          "deployment": {
            "properties": {
              "mode": "incremental",
              "template": {
                "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
                "contentVersion": "1.0.0.0",
                "parameters": {
                  "vmName": {
                    "type": "string"
                  },
                  "location": {
                    "type": "string"
                  }
                },
                "variables": {
                  "vmExtensionName": "ChangeTracking-Windows",
                  "vmExtensionPublisher": "Microsoft.Azure.ChangeTrackingAndInventory",
                  "vmExtensionType": "ChangeTracking-Windows",
                  "vmExtensionTypeHandlerVersion": "2.0"
                },
                "resources": [
                  {
                    "name": "[concat(parameters('vmName'), '/', variables('vmExtensionName'))]",
                    "type": "Microsoft.Compute/virtualMachines/extensions",
                    "location": "[parameters('location')]",
                    "apiVersion": "2019-07-01",
                    "properties": {
                      "publisher": "[variables('vmExtensionPublisher')]",
                      "type": "[variables('vmExtensionType')]",
                      "typeHandlerVersion": "[variables('vmExtensionTypeHandlerVersion')]",
                      "autoUpgradeMinorVersion": true,
                      "enableAutomaticUpgrade": true,
                      "settings": {},
                      "protectedSettings": {}
                    }
                  }
                ]
              },
              "parameters": {
                "vmName": {
                  "value": "[field('name')]"
                },
                "location": {
                  "value": "[field('location')]"
                }
              }
            }
          }
        }
      }
    },
    "versions": [
      "2.2.0",
      "2.1.0",
      "2.0.0-PREVIEW"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/f08f556c-12ff-464d-a7de-40cb5b6cccec",
  "name": "f08f556c-12ff-464d-a7de-40cb5b6cccec"
}
Bylawf08f556c-12ff-464d-a7de-40cb5b6cccec.bylaw.ps1 · 147 lines
# Converted from ASC_ChangeTrackingWindowsAgent_DINE.json by ConvertTo-Bylaw.
Policy 'f08f556c-12ff-464d-a7de-40cb5b6cccec' {

    Properties @{
        DisplayName   = 'Configure ChangeTracking Extension for Windows virtual machines'
        Description   = 'Configure Windows virtual machines to automatically install the ChangeTracking Extension to enable File Integrity Monitoring(FIM) in Azure Security Center. FIM examines operating system files, Windows registries, application software, Linux system files, and more, for changes that might indicate an attack. The extension can be installed in virtual machines and locations supported by Azure Monitor Agent.'
        Version       = '2.2.0'
        Category      = 'Security Center'
        PolicyVersion = '2.2.0'
        Mode          = 'Indexed'
    }

    Parameter Effect @{
        AllowedValues = @('DeployIfNotExists', 'Disabled')
        Default       = 'DeployIfNotExists'
        DisplayName   = 'Effect'
        Description   = 'Enable or disable the execution of the policy'
    }
    Parameter ListOfApplicableLocations @{
        Type          = 'Array'
        AllowedValues = @('australiacentral', 'australiacentral2', 'australiaeast', 'australiasoutheast', 'brazilsouth', 'brazilsoutheast', 'canadacentral', 'canadaeast', 'centralindia', 'centralus', 'centraluseuap', 'eastasia', 'eastus', 'eastus2', 'eastus2euap', 'francecentral', 'francesouth', 'germanynorth', 'germanywestcentral', 'israelcentral', 'italynorth', 'japaneast', 'japanwest', 'jioindiacentral', 'jioindiawest', 'koreacentral', 'koreasouth', 'malaysiasouth', 'mexicocentral', 'northcentralus', 'northeurope', 'norwayeast', 'norwaywest', 'polandcentral', 'qatarcentral', 'southafricanorth', 'southafricawest', 'southcentralus', 'southeastasia', 'southindia', 'spaincentral', 'swedencentral', 'swedensouth', 'switzerlandnorth', 'switzerlandwest', 'taiwannorth', 'taiwannorthwest', 'uaecentral', 'uaenorth', 'uksouth', 'ukwest', 'westcentralus', 'westeurope', 'westindia', 'westus', 'westus2', 'westus3')
        Default       = @('australiacentral', 'australiacentral2', 'australiaeast', 'australiasoutheast', 'brazilsouth', 'brazilsoutheast', 'canadacentral', 'canadaeast', 'centralindia', 'centralus', 'centraluseuap', 'eastasia', 'eastus', 'eastus2', 'eastus2euap', 'francecentral', 'francesouth', 'germanynorth', 'germanywestcentral', 'israelcentral', 'italynorth', 'japaneast', 'japanwest', 'jioindiacentral', 'jioindiawest', 'koreacentral', 'koreasouth', 'malaysiasouth', 'mexicocentral', 'northcentralus', 'northeurope', 'norwayeast', 'norwaywest', 'polandcentral', 'qatarcentral', 'southafricanorth', 'southafricawest', 'southcentralus', 'southeastasia', 'southindia', 'spaincentral', 'swedencentral', 'swedensouth', 'switzerlandnorth', 'switzerlandwest', 'taiwannorth', 'taiwannorthwest', 'uaecentral', 'uaenorth', 'uksouth', 'ukwest', 'westcentralus', 'westeurope', 'westindia', 'westus', 'westus2', 'westus3')
        DisplayName   = 'Applicable Locations'
        Description   = 'The list of locations where the policy should be applied.'
        Metadata      = [ordered]@{ strongType = 'location' }
    }

    Resource 'Microsoft.Compute/virtualMachines' {

        When {
            Field location | Must -BeIn (Param ListOfApplicableLocations)
        }

        Require 'storageProfile.osDisk.osType, imageId and storageProfile.osDisk.createOption are as required' {
            AnyOf {
                Field storageProfile.osDisk.osType | Must -Not -BeLike 'Windows*' -IfPresent
                AllOf {
                    Field 'Microsoft.Compute/imageId' | Must -Not -ContainText 'Microsoft.Compute/galleries' -IfPresent
                    Field 'Microsoft.Compute/imageId' | Must -Not -ContainText 'Microsoft.Compute/images' -IfPresent
                    Field storageProfile.osDisk.createOption | Must -Not -Be 'Attach' -IfPresent
                }
            }
        }

        Require 'imagePublisher, imageOffer and imageSku are as required' {
            AnyOf {
                Field 'Microsoft.Compute/imagePublisher' | Must -Not -Be 'MicrosoftWindowsServer' -IfPresent
                Field 'Microsoft.Compute/imageOffer' | Must -Not -Be 'WindowsServer' -IfPresent
                AllOf {
                    Field 'Microsoft.Compute/imageSku' | Must -Not -BeLike '2008-R2-SP1*' -IfPresent
                    Field 'Microsoft.Compute/imageSku' | Must -Not -BeLike '2012-*' -IfPresent
                    Field 'Microsoft.Compute/imageSku' | Must -Not -BeLike '2016-*' -IfPresent
                    Field 'Microsoft.Compute/imageSku' | Must -Not -BeLike '2019-*' -IfPresent
                    Field 'Microsoft.Compute/imageSku' | Must -Not -BeLike '2022-*' -IfPresent
                    Field 'Microsoft.Compute/imageSku' | Must -Not -BeLike '2025-*' -IfPresent
                }
            }
        }

        Require 'imagePublisher, imageOffer and imageSKU are as required' {
            AnyOf {
                Field 'Microsoft.Compute/imagePublisher' | Must -Not -Be 'MicrosoftWindowsServer' -IfPresent
                Field 'Microsoft.Compute/imageOffer' | Must -Not -Be 'WindowsServerSemiAnnual' -IfPresent
                Field 'Microsoft.Compute/imageSKU' | Must -Not -BeIn @('Datacenter-Core-1709-smalldisk', 'Datacenter-Core-1709-with-Containers-smalldisk', 'Datacenter-Core-1803-with-Containers-smalldisk') -IfPresent
            }
        }

        Require 'imagePublisher and imageOffer are as required' {
            AnyOf {
                Field 'Microsoft.Compute/imagePublisher' | Must -Not -Be 'MicrosoftWindowsServerHPCPack' -IfPresent
                Field 'Microsoft.Compute/imageOffer' | Must -Not -Be 'WindowsServerHPCPack' -IfPresent
            }
        }

        Require 'imagePublisher and imageOffer are as required' {
            AnyOf {
                Field 'Microsoft.Compute/imagePublisher' | Must -Not -Be 'MicrosoftSQLServer' -IfPresent
                AllOf {
                    Field 'Microsoft.Compute/imageOffer' | Must -Not -BeLike '*-WS2022' -IfPresent
                    Field 'Microsoft.Compute/imageOffer' | Must -Not -BeLike '*-WS2022-BYOL' -IfPresent
                    Field 'Microsoft.Compute/imageOffer' | Must -Not -BeLike '*-WS2019' -IfPresent
                    Field 'Microsoft.Compute/imageOffer' | Must -Not -BeLike '*-WS2019-BYOL' -IfPresent
                    Field 'Microsoft.Compute/imageOffer' | Must -Not -BeLike '*-WS2016' -IfPresent
                    Field 'Microsoft.Compute/imageOffer' | Must -Not -BeLike '*-WS2016-BYOL' -IfPresent
                    Field 'Microsoft.Compute/imageOffer' | Must -Not -BeLike '*-WS2012R2' -IfPresent
                    Field 'Microsoft.Compute/imageOffer' | Must -Not -BeLike '*-WS2012R2-BYOL' -IfPresent
                }
            }
        }

        Require 'imagePublisher and imageOffer are as required' {
            AnyOf {
                Field 'Microsoft.Compute/imagePublisher' | Must -Not -Be 'MicrosoftRServer' -IfPresent
                Field 'Microsoft.Compute/imageOffer' | Must -Not -Be 'MLServer-WS2016' -IfPresent
            }
        }

        Require 'imagePublisher and imageOffer are as required' {
            AnyOf {
                Field 'Microsoft.Compute/imagePublisher' | Must -Not -Be 'MicrosoftVisualStudio' -IfPresent
                Field 'Microsoft.Compute/imageOffer' | Must -Not -BeIn @('VisualStudio', 'Windows') -IfPresent
            }
        }

        Require 'imagePublisher, imageOffer and imageSKU are as required' {
            AnyOf {
                Field 'Microsoft.Compute/imagePublisher' | Must -Not -Be 'MicrosoftDynamicsAX' -IfPresent
                Field 'Microsoft.Compute/imageOffer' | Must -Not -Be 'Dynamics' -IfPresent
                Field 'Microsoft.Compute/imageSKU' | Must -Not -Be 'Pre-Req-AX7-Onebox-U8' -IfPresent
            }
        }

        Require 'imagePublisher and imageOffer are as required' {
            AnyOf {
                Field 'Microsoft.Compute/imagePublisher' | Must -Not -Be 'microsoft-ads' -IfPresent
                Field 'Microsoft.Compute/imageOffer' | Must -Not -Be 'windows-data-science-vm' -IfPresent
            }
        }

        Require 'imagePublisher and imageOffer are as required' {
            AnyOf {
                Field 'Microsoft.Compute/imagePublisher' | Must -Not -Be 'MicrosoftWindowsDesktop' -IfPresent
                Field 'Microsoft.Compute/imageOffer' | Must -Not -BeIn @('Windows-10', 'Windows-11') -IfPresent
            }
        }

        Require 'imagePublisher, imageOffer and imageSKU are as required' {
            AnyOf {
                Field 'Microsoft.Compute/imagePublisher' | Must -Not -Be 'center-for-internet-security-inc' -IfPresent
                Field 'Microsoft.Compute/imageOffer' | Must -Not -Be 'cis-windows-server' -IfPresent
                Field 'Microsoft.Compute/imageSKU' | Must -Not -Be 'cis-windows-server2022-l1-gen1' -IfPresent
            }
        }
    }

    DeployIfNotExists 'Microsoft.Compute/virtualMachines/extensions' -Role 'Virtual Machine Contributor' -Effect (Param Effect) {
        Require 'type, publisher and provisioningState are as required' {
            Field 'Microsoft.Compute/virtualMachines/extensions/type' | Must -Be 'ChangeTracking-Windows'
            Field publisher | Must -Be 'Microsoft.Azure.ChangeTrackingAndInventory'
            Field provisioningState | Must -Be 'Succeeded'
        }
        Deployment -TemplateFile './templates/f08f556c-12ff-464d-a7de-40cb5b6cccec.json' -Parameters ([ordered]@{
                vmName   = (Arm '[field(''name'')]')
                location = (Arm '[field(''location'')]')
            })
    }
}

Its deployment templates are written beside it:

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