Bylaw

Gallery › Monitoring › Azure built-in policies

Configure Linux Virtual Machine Scale Sets to be associated with a Data Collection Rule or a Data Collection Endpoint

Converted Policy DeployIfNotExists Disabled Mode Indexed Version 4.14.0

Deploy Association to link Linux virtual machine scale sets to the specified Data Collection Rule or the specified Data Collection Endpoint. The list of locations and OS images are updated over time as support is increased.

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

Azure Policy JSONAzureMonitor_DCRA_VMSS_Linux_DINE.json · 793 lines
{
  "properties": {
    "displayName": "Configure Linux Virtual Machine Scale Sets to be associated with a Data Collection Rule or a Data Collection Endpoint",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "Deploy Association to link Linux virtual machine scale sets to the specified Data Collection Rule or the specified Data Collection Endpoint. The list of locations and OS images are updated over time as support is increased.",
    "metadata": {
      "version": "4.14.0",
      "category": "Monitoring"
    },
    "version": "4.14.0",
    "parameters": {
      "effect": {
        "type": "String",
        "metadata": {
          "displayName": "Effect",
          "description": "Enable or disable the execution of the policy."
        },
        "allowedValues": [
          "DeployIfNotExists",
          "Disabled"
        ],
        "defaultValue": "DeployIfNotExists"
      },
      "scopeToSupportedImages": {
        "type": "Boolean",
        "metadata": {
          "displayName": "Scope Policy to Azure Monitor Agent-Supported Operating Systems",
          "description": "If set to true, the policy will apply only to virtual machine scale sets with AMA-supported operating systems. Otherwise, the policy will apply to all virtual machine scale set resources in the assignment scope. For supported operating systems, see https://aka.ms/AMAOverview."
        },
        "allowedValues": [
          true,
          false
        ],
        "defaultValue": true
      },
      "listOfLinuxImageIdToInclude": {
        "type": "Array",
        "metadata": {
          "displayName": "Additional Linux Machine Images",
          "description": "List of virtual machine scale set images that have supported Linux OS to add to scope. Example values: '/subscriptions/<subscriptionId>/resourceGroups/YourResourceGroup/providers/Microsoft.Compute/images/ContosoStdImage'"
        },
        "defaultValue": []
      },
      "dcrResourceId": {
        "type": "String",
        "metadata": {
          "displayName": "Data Collection Rule Resource Id or Data Collection Endpoint Resource Id",
          "description": "Resource Id of the Data Collection Rule or the Data Collection Endpoint to be applied on the Linux machines in scope.",
          "portalReview": "true",
          "assignPermissions": true
        }
      },
      "resourceType": {
        "type": "String",
        "metadata": {
          "displayName": "Resource Type",
          "description": "Either a Data Collection Rule (DCR) or a Data Collection Endpoint (DCE)",
          "portalReview": "true"
        },
        "allowedValues": [
          "Microsoft.Insights/dataCollectionRules",
          "Microsoft.Insights/dataCollectionEndpoints"
        ],
        "defaultValue": "Microsoft.Insights/dataCollectionRules"
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "equals": "Microsoft.Compute/virtualMachineScaleSets"
          },
          {
            "field": "location",
            "in": [
              "australiacentral",
              "australiacentral2",
              "australiaeast",
              "australiasoutheast",
              "brazilsouth",
              "brazilsoutheast",
              "canadacentral",
              "canadaeast",
              "centralindia",
              "centralus",
              "centraluseuap",
              "chilecentral",
              "eastasia",
              "eastus",
              "eastus2",
              "eastus2euap",
              "francecentral",
              "francesouth",
              "germanynorth",
              "germanywestcentral",
              "indonesiacentral",
              "israelcentral",
              "italynorth",
              "japaneast",
              "japanwest",
              "jioindiacentral",
              "jioindiawest",
              "koreacentral",
              "koreasouth",
              "malaysiasouth",
              "malaysiawest",
              "mexicocentral",
              "newzealandnorth",
              "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"
            ]
          },
          {
            "anyOf": [
              {
                "allOf": [
                  {
                    "value": "[parameters('scopeToSupportedImages')]",
                    "equals": false
                  },
                  {
                    "field": "Microsoft.Compute/virtualMachineScaleSets/virtualMachineProfile.storageProfile.osDisk.osType",
                    "like": "Linux*"
                  }
                ]
              },
              {
                "field": "Microsoft.Compute/imageId",
                "in": "[parameters('listOfLinuxImageIdToInclude')]"
              },
              {
                "allOf": [
                  {
                    "field": "Microsoft.Compute/imagePublisher",
                    "equals": "RedHat"
                  },
                  {
                    "field": "Microsoft.Compute/imageOffer",
                    "in": [
                      "RHEL",
                      "RHEL-ARM64",
                      "RHEL-BYOS",
                      "RHEL-HA",
                      "RHEL-SAP",
                      "RHEL-SAP-APPS",
                      "RHEL-SAP-HA",
                      "RHEL-SAP-HANA"
                    ]
                  },
                  {
                    "anyOf": [
                      {
                        "field": "Microsoft.Compute/imageSku",
                        "like": "7*"
                      },
                      {
                        "field": "Microsoft.Compute/imageSku",
                        "like": "8*"
                      },
                      {
                        "field": "Microsoft.Compute/imageSku",
                        "like": "9*"
                      },
                      {
                        "field": "Microsoft.Compute/imageSku",
                        "like": "10*"
                      },
                      {
                        "field": "Microsoft.Compute/imageSku",
                        "like": "rhel-lvm7*"
                      },
                      {
                        "field": "Microsoft.Compute/imageSku",
                        "like": "rhel-lvm8*"
                      },
                      {
                        "field": "Microsoft.Compute/imageSku",
                        "like": "rhel-lvm9*"
                      },
                      {
                        "field": "Microsoft.Compute/imageSku",
                        "like": "rhel-lvm10*"
                      }
                    ]
                  }
                ]
              },
              {
                "allOf": [
                  {
                    "field": "Microsoft.Compute/imagePublisher",
                    "equals": "SUSE"
                  },
                  {
                    "anyOf": [
                      {
                        "allOf": [
                          {
                            "field": "Microsoft.Compute/imageOffer",
                            "in": [
                              "SLES",
                              "SLES-HPC",
                              "SLES-HPC-Priority",
                              "SLES-SAP",
                              "SLES-SAP-BYOS",
                              "SLES-Priority",
                              "SLES-BYOS",
                              "SLES-SAPCAL",
                              "SLES-Standard"
                            ]
                          },
                          {
                            "anyOf": [
                              {
                                "field": "Microsoft.Compute/imageSku",
                                "like": "15*"
                              },
                              {
                                "field": "Microsoft.Compute/imageSku",
                                "like": "16*"
                              }
                            ]
                          }
                        ]
                      },
                      {
                        "allOf": [
                          {
                            "anyOf": [
                              {
                                "field": "Microsoft.Compute/imageOffer",
                                "equals": "sles-12-sp5"
                              },
                              {
                                "field": "Microsoft.Compute/imageOffer",
                                "like": "sles-15*"
                              },
                              {
                                "field": "Microsoft.Compute/imageOffer",
                                "like": "sles-16*"
                              }
                            ]
                          },
                          {
                            "field": "Microsoft.Compute/imageSku",
                            "in": [
                              "gen1",
                              "gen2"
                            ]
                          }
                        ]
                      }
                    ]
                  }
                ]
              },
              {
                "allOf": [
                  {
                    "field": "Microsoft.Compute/imagePublisher",
                    "equals": "Canonical"
                  },
                  {
                    "anyOf": [
                      {
                        "field": "Microsoft.Compute/imageOffer",
                        "equals": "UbuntuServer"
                      },
                      {
                        "field": "Microsoft.Compute/imageOffer",
                        "like": "0001-com-ubuntu-server-*"
                      },
                      {
                        "field": "Microsoft.Compute/imageOffer",
                        "like": "0001-com-ubuntu-pro-*"
                      },
                      {
                        "field": "Microsoft.Compute/imageOffer",
                        "like": "ubuntu-24_04-lts*"
                      },
                      {
                        "field": "Microsoft.Compute/imageOffer",
                        "like": "ubuntu-26_04-lts*"
                      }
                    ]
                  },
                  {
                    "field": "Microsoft.Compute/imageSku",
                    "in": [
                      "16_04_0-lts-gen2",
                      "16_04-lts-gen2",
                      "16.04-lts",
                      "16.04.0-lts",
                      "18_04-lts-arm64",
                      "18_04-lts-gen2",
                      "18.04-lts",
                      "20_04-lts-arm64",
                      "20_04-lts-gen2",
                      "20_04-lts",
                      "22_04-lts-arm64",
                      "22_04-lts-gen2",
                      "22_04-lts",
                      "server-arm64",
                      "server",
                      "pro-16_04-lts-gen2",
                      "pro-16_04-lts",
                      "pro-18_04-lts-gen2",
                      "pro-18_04-lts",
                      "pro-20_04-lts-gen2",
                      "pro-20_04-lts",
                      "pro-22_04-lts-gen2",
                      "pro-22_04-lts",
                      "24_04-gen2",
                      "pro-24_04"
                    ]
                  }
                ]
              },
              {
                "allOf": [
                  {
                    "field": "Microsoft.Compute/imagePublisher",
                    "equals": "Oracle"
                  },
                  {
                    "field": "Microsoft.Compute/imageOffer",
                    "equals": "Oracle-Linux"
                  },
                  {
                    "anyOf": [
                      {
                        "field": "Microsoft.Compute/imageSku",
                        "like": "7*"
                      },
                      {
                        "field": "Microsoft.Compute/imageSku",
                        "like": "8*"
                      },
                      {
                        "field": "Microsoft.Compute/imageSku",
                        "like": "ol7*"
                      },
                      {
                        "field": "Microsoft.Compute/imageSku",
                        "like": "ol8*"
                      },
                      {
                        "field": "Microsoft.Compute/imageSku",
                        "like": "ol9*"
                      },
                      {
                        "field": "Microsoft.Compute/imageSku",
                        "like": "ol10*"
                      },
                      {
                        "field": "Microsoft.Compute/imageSku",
                        "like": "9*"
                      }
                    ]
                  },
                  {
                    "field": "Microsoft.Compute/imageSku",
                    "notContains": "arm64"
                  }
                ]
              },
              {
                "allOf": [
                  {
                    "field": "Microsoft.Compute/imagePublisher",
                    "equals": "Oracle"
                  },
                  {
                    "field": "Microsoft.Compute/imageOffer",
                    "equals": "Oracle-Linux"
                  },
                  {
                    "field": "Microsoft.Compute/imageSku",
                    "equals": "ol10-arm64-lvm-gen2"
                  }
                ]
              },
              {
                "allOf": [
                  {
                    "field": "Microsoft.Compute/imagePublisher",
                    "equals": "almalinux"
                  },
                  {
                    "field": "Microsoft.Compute/imageOffer",
                    "like": "almalinux*"
                  },
                  {
                    "anyOf": [
                      {
                        "field": "Microsoft.Compute/imageSku",
                        "like": "8*"
                      },
                      {
                        "allOf": [
                          {
                            "field": "Microsoft.Compute/imageSku",
                            "like": "9*"
                          },
                          {
                            "field": "Microsoft.Compute/imageSku",
                            "notContains": "arm"
                          }
                        ]
                      },
                      {
                        "allOf": [
                          {
                            "field": "Microsoft.Compute/imageOffer",
                            "equals": "almalinux-x86_64"
                          },
                          {
                            "field": "Microsoft.Compute/imageSku",
                            "equals": "10-gen2"
                          }
                        ]
                      }
                    ]
                  }
                ]
              },
              {
                "allOf": [
                  {
                    "field": "Microsoft.Compute/imagePublisher",
                    "equals": "almalinux"
                  },
                  {
                    "field": "Microsoft.Compute/imageOffer",
                    "equals": "almalinux-arm"
                  },
                  {
                    "field": "Microsoft.Compute/imageSku",
                    "equals": "10-arm64-gen2"
                  }
                ]
              },
              {
                "allOf": [
                  {
                    "field": "Microsoft.Compute/imagePublisher",
                    "equals": "ciq"
                  },
                  {
                    "field": "Microsoft.Compute/imageOffer",
                    "equals": "rocky-community-editions"
                  },
                  {
                    "field": "Microsoft.Compute/imageSku",
                    "in": [
                      "rocky-community-8-arm",
                      "rocky-community-9-arm",
                      "rocky-community-8",
                      "rocky-community-9",
                      "rocky-community-10",
                      "rocky-community-10-arm"
                    ]
                  }
                ]
              },
              {
                "allOf": [
                  {
                    "field": "Microsoft.Compute/imagePublisher",
                    "equals": "resf"
                  },
                  {
                    "field": "Microsoft.Compute/imageOffer",
                    "equals": "rockylinux-x86_64"
                  },
                  {
                    "field": "Microsoft.Compute/imageSku",
                    "in": [
                      "8-lvm",
                      "9-base",
                      "10-base",
                      "10-lvm"
                    ]
                  }
                ]
              },
              {
                "allOf": [
                  {
                    "field": "Microsoft.Compute/imagePublisher",
                    "equals": "resf"
                  },
                  {
                    "field": "Microsoft.Compute/imageOffer",
                    "equals": "rockylinux-aarch64"
                  },
                  {
                    "field": "Microsoft.Compute/imageSku",
                    "in": [
                      "rockylinux-aarch64-8",
                      "rockylinux-aarch64-9",
                      "rockylinux-aarch64-9-lvm",
                      "10-base",
                      "10-lvm"
                    ]
                  }
                ]
              },
              {
                "allOf": [
                  {
                    "field": "Microsoft.Compute/imagePublisher",
                    "equals": "credativ"
                  },
                  {
                    "field": "Microsoft.Compute/imageOffer",
                    "in": [
                      "Debian"
                    ]
                  },
                  {
                    "field": "Microsoft.Compute/imageSku",
                    "equals": "9"
                  }
                ]
              },
              {
                "allOf": [
                  {
                    "field": "Microsoft.Compute/imagePublisher",
                    "equals": "Debian"
                  },
                  {
                    "field": "Microsoft.Compute/imageOffer",
                    "in": [
                      "debian-10",
                      "debian-11",
                      "debian-12",
                      "debian-13"
                    ]
                  },
                  {
                    "field": "Microsoft.Compute/imageSku",
                    "in": [
                      "10",
                      "10-gen2",
                      "11",
                      "11-gen2",
                      "12",
                      "12-gen2",
                      "13",
                      "13-gen2",
                      "11-backports-arm64",
                      "11-backports-arm64-v2",
                      "12-backports-arm64",
                      "13-backports-arm64"
                    ]
                  }
                ]
              },
              {
                "allOf": [
                  {
                    "field": "Microsoft.Compute/imagePublisher",
                    "equals": "microsoftcblmariner"
                  },
                  {
                    "field": "Microsoft.Compute/imageOffer",
                    "in": [
                      "cbl-mariner",
                      "azure-linux-3"
                    ]
                  },
                  {
                    "anyOf": [
                      {
                        "field": "Microsoft.Compute/imageSku",
                        "like": "cbl-mariner-2*"
                      },
                      {
                        "field": "Microsoft.Compute/imageSku",
                        "like": "azure-linux-3*"
                      }
                    ]
                  }
                ]
              },
              {
                "allOf": [
                  {
                    "field": "Microsoft.Compute/imagePublisher",
                    "equals": "microsoftazurelinux"
                  },
                  {
                    "field": "Microsoft.Compute/imageOffer",
                    "equals": "azurelinux-4"
                  },
                  {
                    "field": "Microsoft.Compute/imageSku",
                    "in": [
                      "4",
                      "4-arm64"
                    ]
                  }
                ]
              },
              {
                "allOf": [
                  {
                    "field": "Microsoft.Compute/imagePublisher",
                    "equals": "SUSE"
                  },
                  {
                    "field": "Microsoft.Compute/imageOffer",
                    "like": "opensuse-leap-15*"
                  },
                  {
                    "field": "Microsoft.Compute/imageOffer",
                    "notContains": "arm64"
                  },
                  {
                    "field": "Microsoft.Compute/imageSku",
                    "in": [
                      "gen1",
                      "gen2"
                    ]
                  }
                ]
              },
              {
                "allOf": [
                  {
                    "field": "Microsoft.Compute/imagePublisher",
                    "equals": "susellc"
                  },
                  {
                    "field": "Microsoft.Compute/imageOffer",
                    "in": [
                      "opensuse-leap-x86-64"
                    ]
                  },
                  {
                    "field": "Microsoft.Compute/imageSku",
                    "in": [
                      "gen1",
                      "gen2"
                    ]
                  }
                ]
              }
            ]
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]",
        "details": {
          "type": "Microsoft.Insights/dataCollectionRuleAssociations",
          "roleDefinitionIds": [
            "/providers/microsoft.authorization/roleDefinitions/749f88d5-cbae-40b8-bcfc-e573ddc772fa",
            "/providers/microsoft.authorization/roleDefinitions/92aaf0da-9dab-42b6-94a3-d43ce8d16293"
          ],
          "evaluationDelay": "AfterProvisioning",
          "existenceCondition": {
            "anyOf": [
              {
                "field": "Microsoft.Insights/dataCollectionRuleAssociations/dataCollectionRuleId",
                "equals": "[parameters('dcrResourceId')]"
              },
              {
                "field": "Microsoft.Insights/dataCollectionRuleAssociations/dataCollectionEndpointId",
                "equals": "[parameters('dcrResourceId')]"
              }
            ]
          },
          "deployment": {
            "properties": {
              "mode": "incremental",
              "template": {
                "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
                "contentVersion": "1.0.0.0",
                "parameters": {
                  "resourceName": {
                    "type": "string"
                  },
                  "location": {
                    "type": "string"
                  },
                  "dcrResourceId": {
                    "type": "string"
                  },
                  "resourceType": {
                    "type": "string"
                  }
                },
                "variables": {
                  "dcrAssociationName": "[concat('assoc-', uniqueString(concat(parameters('resourceName'), parameters('dcrResourceId'))))]",
                  "dceAssociationName": "configurationAccessEndpoint",
                  "dcrResourceType": "Microsoft.Insights/dataCollectionRules",
                  "dceResourceType": "Microsoft.Insights/dataCollectionEndpoints"
                },
                "resources": [
                  {
                    "condition": "[equals(parameters('resourceType'), variables('dcrResourceType'))]",
                    "name": "[variables('dcrAssociationName')]",
                    "type": "Microsoft.Insights/dataCollectionRuleAssociations",
                    "apiVersion": "2021-04-01",
                    "properties": {
                      "dataCollectionRuleId": "[parameters('dcrResourceId')]"
                    },
                    "scope": "[concat('Microsoft.Compute/virtualMachineScaleSets/', parameters('resourceName'))]"
                  },
                  {
                    "condition": "[equals(parameters('resourceType'), variables('dceResourceType'))]",
                    "name": "[variables('dceAssociationName')]",
                    "type": "Microsoft.Insights/dataCollectionRuleAssociations",
                    "apiVersion": "2021-04-01",
                    "properties": {
                      "dataCollectionEndpointId": "[parameters('dcrResourceId')]"
                    },
                    "scope": "[concat('Microsoft.Compute/virtualMachineScaleSets/', parameters('resourceName'))]"
                  }
                ]
              },
              "parameters": {
                "resourceName": {
                  "value": "[field('name')]"
                },
                "location": {
                  "value": "[field('location')]"
                },
                "dcrResourceId": {
                  "value": "[parameters('dcrResourceId')]"
                },
                "resourceType": {
                  "value": "[parameters('resourceType')]"
                }
              }
            }
          }
        }
      }
    },
    "versions": [
      "4.14.0",
      "4.13.0",
      "4.12.0",
      "4.11.0",
      "4.10.0",
      "4.9.0",
      "4.8.0",
      "4.7.0",
      "4.6.0",
      "4.5.0",
      "4.4.1",
      "4.4.0",
      "4.3.0",
      "4.2.0",
      "4.1.0",
      "4.0.1"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/050a90d5-7cce-483f-8f6c-0df462036dda",
  "name": "050a90d5-7cce-483f-8f6c-0df462036dda"
}
Bylaw050a90d5-7cce-483f-8f6c-0df462036dda.bylaw.ps1 · 259 lines
# Converted from AzureMonitor_DCRA_VMSS_Linux_DINE.json by ConvertTo-Bylaw.
Policy '050a90d5-7cce-483f-8f6c-0df462036dda' {

    Properties @{
        DisplayName   = 'Configure Linux Virtual Machine Scale Sets to be associated with a Data Collection Rule or a Data Collection Endpoint'
        Description   = 'Deploy Association to link Linux virtual machine scale sets to the specified Data Collection Rule or the specified Data Collection Endpoint. The list of locations and OS images are updated over time as support is increased.'
        Version       = '4.14.0'
        Category      = 'Monitoring'
        PolicyVersion = '4.14.0'
        Mode          = 'Indexed'
    }

    Parameter Effect @{
        AllowedValues = @('DeployIfNotExists', 'Disabled')
        Default       = 'DeployIfNotExists'
        DisplayName   = 'Effect'
        Description   = 'Enable or disable the execution of the policy.'
    }
    Parameter ScopeToSupportedImages @{
        Type          = 'Boolean'
        AllowedValues = @($true, $false)
        Default       = $true
        DisplayName   = 'Scope Policy to Azure Monitor Agent-Supported Operating Systems'
        Description   = 'If set to true, the policy will apply only to virtual machine scale sets with AMA-supported operating systems. Otherwise, the policy will apply to all virtual machine scale set resources in the assignment scope. For supported operating systems, see https://aka.ms/AMAOverview.'
    }
    Parameter ListOfLinuxImageIdToInclude @{
        Type        = 'Array'
        Default     = @()
        DisplayName = 'Additional Linux Machine Images'
        Description = 'List of virtual machine scale set images that have supported Linux OS to add to scope. Example values: ''/subscriptions/<subscriptionId>/resourceGroups/YourResourceGroup/providers/Microsoft.Compute/images/ContosoStdImage'''
    }
    Parameter DcrResourceId @{
        Type        = 'String'
        DisplayName = 'Data Collection Rule Resource Id or Data Collection Endpoint Resource Id'
        Description = 'Resource Id of the Data Collection Rule or the Data Collection Endpoint to be applied on the Linux machines in scope.'
        Metadata    = [ordered]@{ portalReview = 'true'; assignPermissions = $true }
    }
    Parameter ResourceType @{
        AllowedValues = @('Microsoft.Insights/dataCollectionRules', 'Microsoft.Insights/dataCollectionEndpoints')
        Default       = 'Microsoft.Insights/dataCollectionRules'
        DisplayName   = 'Resource Type'
        Description   = 'Either a Data Collection Rule (DCR) or a Data Collection Endpoint (DCE)'
        Metadata      = [ordered]@{ portalReview = 'true' }
    }

    Resource 'Microsoft.Compute/virtualMachineScaleSets' {

        When {
            Field location | Must -BeIn @('australiacentral', 'australiacentral2', 'australiaeast', 'australiasoutheast', 'brazilsouth', 'brazilsoutheast', 'canadacentral', 'canadaeast', 'centralindia', 'centralus', 'centraluseuap', 'chilecentral', 'eastasia', 'eastus', 'eastus2', 'eastus2euap', 'francecentral', 'francesouth', 'germanynorth', 'germanywestcentral', 'indonesiacentral', 'israelcentral', 'italynorth', 'japaneast', 'japanwest', 'jioindiacentral', 'jioindiawest', 'koreacentral', 'koreasouth', 'malaysiasouth', 'malaysiawest', 'mexicocentral', 'newzealandnorth', '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')
        }

        Require 'virtualMachineProfile.storageProfile.osDisk.osType is as required' {
            AnyOf {
                Param ScopeToSupportedImages | Must -Not -Be $false
                Field virtualMachineProfile.storageProfile.osDisk.osType | Must -Not -BeLike 'Linux*' -IfPresent
            }
        }

        Require 'imageId is not one of the ListOfLinuxImageIdToInclude parameter' {
            Field 'Microsoft.Compute/imageId' | Must -Not -BeIn (Param ListOfLinuxImageIdToInclude) -IfPresent
        }

        Require 'imagePublisher, imageOffer and imageSku are as required' {
            AnyOf {
                Field 'Microsoft.Compute/imagePublisher' | Must -Not -Be 'RedHat' -IfPresent
                Field 'Microsoft.Compute/imageOffer' | Must -Not -BeIn @('RHEL', 'RHEL-ARM64', 'RHEL-BYOS', 'RHEL-HA', 'RHEL-SAP', 'RHEL-SAP-APPS', 'RHEL-SAP-HA', 'RHEL-SAP-HANA') -IfPresent
                AllOf {
                    Field 'Microsoft.Compute/imageSku' | Must -Not -BeLike '7*' -IfPresent
                    Field 'Microsoft.Compute/imageSku' | Must -Not -BeLike '8*' -IfPresent
                    Field 'Microsoft.Compute/imageSku' | Must -Not -BeLike '9*' -IfPresent
                    Field 'Microsoft.Compute/imageSku' | Must -Not -BeLike '10*' -IfPresent
                    Field 'Microsoft.Compute/imageSku' | Must -Not -BeLike 'rhel-lvm7*' -IfPresent
                    Field 'Microsoft.Compute/imageSku' | Must -Not -BeLike 'rhel-lvm8*' -IfPresent
                    Field 'Microsoft.Compute/imageSku' | Must -Not -BeLike 'rhel-lvm9*' -IfPresent
                    Field 'Microsoft.Compute/imageSku' | Must -Not -BeLike 'rhel-lvm10*' -IfPresent
                }
            }
        }

        Require 'imagePublisher, imageOffer and imageSku are as required' {
            AnyOf {
                Field 'Microsoft.Compute/imagePublisher' | Must -Not -Be 'SUSE' -IfPresent
                AllOf {
                    AnyOf {
                        Field 'Microsoft.Compute/imageOffer' | Must -Not -BeIn @('SLES', 'SLES-HPC', 'SLES-HPC-Priority', 'SLES-SAP', 'SLES-SAP-BYOS', 'SLES-Priority', 'SLES-BYOS', 'SLES-SAPCAL', 'SLES-Standard') -IfPresent
                        AllOf {
                            Field 'Microsoft.Compute/imageSku' | Must -Not -BeLike '15*' -IfPresent
                            Field 'Microsoft.Compute/imageSku' | Must -Not -BeLike '16*' -IfPresent
                        }
                    }
                    AnyOf {
                        AllOf {
                            Field 'Microsoft.Compute/imageOffer' | Must -Not -Be 'sles-12-sp5' -IfPresent
                            Field 'Microsoft.Compute/imageOffer' | Must -Not -BeLike 'sles-15*' -IfPresent
                            Field 'Microsoft.Compute/imageOffer' | Must -Not -BeLike 'sles-16*' -IfPresent
                        }
                        Field 'Microsoft.Compute/imageSku' | Must -Not -BeIn @('gen1', 'gen2') -IfPresent
                    }
                }
            }
        }

        Require 'imagePublisher, imageOffer and imageSku are as required' {
            AnyOf {
                Field 'Microsoft.Compute/imagePublisher' | Must -Not -Be 'Canonical' -IfPresent
                AllOf {
                    Field 'Microsoft.Compute/imageOffer' | Must -Not -Be 'UbuntuServer' -IfPresent
                    Field 'Microsoft.Compute/imageOffer' | Must -Not -BeLike '0001-com-ubuntu-server-*' -IfPresent
                    Field 'Microsoft.Compute/imageOffer' | Must -Not -BeLike '0001-com-ubuntu-pro-*' -IfPresent
                    Field 'Microsoft.Compute/imageOffer' | Must -Not -BeLike 'ubuntu-24_04-lts*' -IfPresent
                    Field 'Microsoft.Compute/imageOffer' | Must -Not -BeLike 'ubuntu-26_04-lts*' -IfPresent
                }
                Field 'Microsoft.Compute/imageSku' | Must -Not -BeIn @('16_04_0-lts-gen2', '16_04-lts-gen2', '16.04-lts', '16.04.0-lts', '18_04-lts-arm64', '18_04-lts-gen2', '18.04-lts', '20_04-lts-arm64', '20_04-lts-gen2', '20_04-lts', '22_04-lts-arm64', '22_04-lts-gen2', '22_04-lts', 'server-arm64', 'server', 'pro-16_04-lts-gen2', 'pro-16_04-lts', 'pro-18_04-lts-gen2', 'pro-18_04-lts', 'pro-20_04-lts-gen2', 'pro-20_04-lts', 'pro-22_04-lts-gen2', 'pro-22_04-lts', '24_04-gen2', 'pro-24_04') -IfPresent
            }
        }

        Require 'imagePublisher, imageOffer and imageSku are as required' {
            AnyOf {
                Field 'Microsoft.Compute/imagePublisher' | Must -Not -Be 'Oracle' -IfPresent
                Field 'Microsoft.Compute/imageOffer' | Must -Not -Be 'Oracle-Linux' -IfPresent
                AllOf {
                    Field 'Microsoft.Compute/imageSku' | Must -Not -BeLike '7*' -IfPresent
                    Field 'Microsoft.Compute/imageSku' | Must -Not -BeLike '8*' -IfPresent
                    Field 'Microsoft.Compute/imageSku' | Must -Not -BeLike 'ol7*' -IfPresent
                    Field 'Microsoft.Compute/imageSku' | Must -Not -BeLike 'ol8*' -IfPresent
                    Field 'Microsoft.Compute/imageSku' | Must -Not -BeLike 'ol9*' -IfPresent
                    Field 'Microsoft.Compute/imageSku' | Must -Not -BeLike 'ol10*' -IfPresent
                    Field 'Microsoft.Compute/imageSku' | Must -Not -BeLike '9*' -IfPresent
                }
                Field 'Microsoft.Compute/imageSku' | Must -ContainText 'arm64'
            }
        }

        Require 'imagePublisher, imageOffer and imageSku are as required' {
            AnyOf {
                Field 'Microsoft.Compute/imagePublisher' | Must -Not -Be 'Oracle' -IfPresent
                Field 'Microsoft.Compute/imageOffer' | Must -Not -Be 'Oracle-Linux' -IfPresent
                Field 'Microsoft.Compute/imageSku' | Must -Not -Be 'ol10-arm64-lvm-gen2' -IfPresent
            }
        }

        Require 'imagePublisher, imageOffer and imageSku are as required' {
            AnyOf {
                Field 'Microsoft.Compute/imagePublisher' | Must -Not -Be 'almalinux' -IfPresent
                Field 'Microsoft.Compute/imageOffer' | Must -Not -BeLike 'almalinux*' -IfPresent
                AllOf {
                    Field 'Microsoft.Compute/imageSku' | Must -Not -BeLike '8*' -IfPresent
                    AnyOf {
                        Field 'Microsoft.Compute/imageSku' | Must -Not -BeLike '9*' -IfPresent
                        Field 'Microsoft.Compute/imageSku' | Must -ContainText 'arm'
                    }
                    AnyOf {
                        Field 'Microsoft.Compute/imageOffer' | Must -Not -Be 'almalinux-x86_64' -IfPresent
                        Field 'Microsoft.Compute/imageSku' | Must -Not -Be '10-gen2' -IfPresent
                    }
                }
            }
        }

        Require 'imagePublisher, imageOffer and imageSku are as required' {
            AnyOf {
                Field 'Microsoft.Compute/imagePublisher' | Must -Not -Be 'almalinux' -IfPresent
                Field 'Microsoft.Compute/imageOffer' | Must -Not -Be 'almalinux-arm' -IfPresent
                Field 'Microsoft.Compute/imageSku' | Must -Not -Be '10-arm64-gen2' -IfPresent
            }
        }

        Require 'imagePublisher, imageOffer and imageSku are as required' {
            AnyOf {
                Field 'Microsoft.Compute/imagePublisher' | Must -Not -Be 'ciq' -IfPresent
                Field 'Microsoft.Compute/imageOffer' | Must -Not -Be 'rocky-community-editions' -IfPresent
                Field 'Microsoft.Compute/imageSku' | Must -Not -BeIn @('rocky-community-8-arm', 'rocky-community-9-arm', 'rocky-community-8', 'rocky-community-9', 'rocky-community-10', 'rocky-community-10-arm') -IfPresent
            }
        }

        Require 'imagePublisher, imageOffer and imageSku are as required' {
            AnyOf {
                Field 'Microsoft.Compute/imagePublisher' | Must -Not -Be 'resf' -IfPresent
                Field 'Microsoft.Compute/imageOffer' | Must -Not -Be 'rockylinux-x86_64' -IfPresent
                Field 'Microsoft.Compute/imageSku' | Must -Not -BeIn @('8-lvm', '9-base', '10-base', '10-lvm') -IfPresent
            }
        }

        Require 'imagePublisher, imageOffer and imageSku are as required' {
            AnyOf {
                Field 'Microsoft.Compute/imagePublisher' | Must -Not -Be 'resf' -IfPresent
                Field 'Microsoft.Compute/imageOffer' | Must -Not -Be 'rockylinux-aarch64' -IfPresent
                Field 'Microsoft.Compute/imageSku' | Must -Not -BeIn @('rockylinux-aarch64-8', 'rockylinux-aarch64-9', 'rockylinux-aarch64-9-lvm', '10-base', '10-lvm') -IfPresent
            }
        }

        Require 'imagePublisher, imageOffer and imageSku are as required' {
            AnyOf {
                Field 'Microsoft.Compute/imagePublisher' | Must -Not -Be 'credativ' -IfPresent
                Field 'Microsoft.Compute/imageOffer' | Must -Not -BeIn @('Debian') -IfPresent
                Field 'Microsoft.Compute/imageSku' | Must -Not -Be '9' -IfPresent
            }
        }

        Require 'imagePublisher, imageOffer and imageSku are as required' {
            AnyOf {
                Field 'Microsoft.Compute/imagePublisher' | Must -Not -Be 'Debian' -IfPresent
                Field 'Microsoft.Compute/imageOffer' | Must -Not -BeIn @('debian-10', 'debian-11', 'debian-12', 'debian-13') -IfPresent
                Field 'Microsoft.Compute/imageSku' | Must -Not -BeIn @('10', '10-gen2', '11', '11-gen2', '12', '12-gen2', '13', '13-gen2', '11-backports-arm64', '11-backports-arm64-v2', '12-backports-arm64', '13-backports-arm64') -IfPresent
            }
        }

        Require 'imagePublisher, imageOffer and imageSku are as required' {
            AnyOf {
                Field 'Microsoft.Compute/imagePublisher' | Must -Not -Be 'microsoftcblmariner' -IfPresent
                Field 'Microsoft.Compute/imageOffer' | Must -Not -BeIn @('cbl-mariner', 'azure-linux-3') -IfPresent
                AllOf {
                    Field 'Microsoft.Compute/imageSku' | Must -Not -BeLike 'cbl-mariner-2*' -IfPresent
                    Field 'Microsoft.Compute/imageSku' | Must -Not -BeLike 'azure-linux-3*' -IfPresent
                }
            }
        }

        Require 'imagePublisher, imageOffer and imageSku are as required' {
            AnyOf {
                Field 'Microsoft.Compute/imagePublisher' | Must -Not -Be 'microsoftazurelinux' -IfPresent
                Field 'Microsoft.Compute/imageOffer' | Must -Not -Be 'azurelinux-4' -IfPresent
                Field 'Microsoft.Compute/imageSku' | Must -Not -BeIn @('4', '4-arm64') -IfPresent
            }
        }

        Require 'imagePublisher, imageOffer and imageSku are as required' {
            AnyOf {
                Field 'Microsoft.Compute/imagePublisher' | Must -Not -Be 'SUSE' -IfPresent
                Field 'Microsoft.Compute/imageOffer' | Must -Not -BeLike 'opensuse-leap-15*' -IfPresent
                Field 'Microsoft.Compute/imageOffer' | Must -ContainText 'arm64'
                Field 'Microsoft.Compute/imageSku' | Must -Not -BeIn @('gen1', 'gen2') -IfPresent
            }
        }

        Require 'imagePublisher, imageOffer and imageSku are as required' {
            AnyOf {
                Field 'Microsoft.Compute/imagePublisher' | Must -Not -Be 'susellc' -IfPresent
                Field 'Microsoft.Compute/imageOffer' | Must -Not -BeIn @('opensuse-leap-x86-64') -IfPresent
                Field 'Microsoft.Compute/imageSku' | Must -Not -BeIn @('gen1', 'gen2') -IfPresent
            }
        }
    }

    DeployIfNotExists 'Microsoft.Insights/dataCollectionRuleAssociations' -Role 'Monitoring Contributor', 'Log Analytics Contributor' -EvaluationDelay AfterProvisioning -Effect (Param Effect) {
        Require 'dataCollectionRuleId and dataCollectionEndpointId are as required' {
            AnyOf {
                Field dataCollectionRuleId | Must -Be (Param DcrResourceId)
                Field dataCollectionEndpointId | Must -Be (Param DcrResourceId)
            }
        }
        Deployment -TemplateFile './templates/050a90d5-7cce-483f-8f6c-0df462036dda.json' -Parameters ([ordered]@{
                resourceName  = (Arm '[field(''name'')]')
                location      = (Arm '[field(''location'')]')
                dcrResourceId = (Param DcrResourceId)
                resourceType  = (Param ResourceType)
            })
    }
}

Its deployment templates are written beside it:

Source: built-in-policies/policyDefinitions/Monitoring/AzureMonitor_DCRA_VMSS_Linux_DINE.json in Azure/azure-policy, under the MIT licence.