Bylaw

Gallery › ChangeTrackingAndInventory › Azure built-in policies

Enable ChangeTracking and Inventory for Arc-enabled virtual machines

Converted Initiative Version 1.1.0

Enable ChangeTracking and Inventory for Arc-enabled virtual machines. Takes Data Collection Rule ID as parameter and asks for an option to input applicable locations.

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

Azure Policy JSONHybridVM.json · 251 lines
{
  "properties": {
    "displayName": "Enable ChangeTracking and Inventory for Arc-enabled virtual machines",
    "policyType": "BuiltIn",
    "description": "Enable ChangeTracking and Inventory for Arc-enabled virtual machines. Takes Data Collection Rule ID as parameter and asks for an option to input applicable locations.",
    "metadata": {
      "version": "1.1.0",
      "category": "ChangeTrackingAndInventory"
    },
    "version": "1.1.0",
    "parameters": {
      "effect": {
        "type": "String",
        "metadata": {
          "displayName": "Effect for all constituent policies",
          "description": "Enable or disable the execution of each of the constituent policies in the initiative."
        },
        "allowedValues": [
          "DeployIfNotExists",
          "Disabled"
        ],
        "defaultValue": "DeployIfNotExists"
      },
      "dcrResourceId": {
        "type": "String",
        "metadata": {
          "displayName": "Data Collection Rule Resource Id",
          "description": "Resource Id of the Data Collection Rule to be applied on the virtual machines in scope."
        }
      },
      "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"
        ]
      }
    },
    "policyDefinitions": [
      {
        "policyDefinitionId": "/providers/Microsoft.Authorization/policyDefinitions/a7acfae7-9497-4a3f-a3b5-a16a50abbe2f",
        "definitionVersion": "1.*.*",
        "policyDefinitionReferenceId": "DeployAMAWindowsHybridVMWithUAIChangeTrackingAndInventory",
        "parameters": {
          "effect": {
            "value": "[parameters('effect')]"
          },
          "listOfApplicableLocations": {
            "value": "[parameters('listOfApplicableLocations')]"
          }
        }
      },
      {
        "policyDefinitionId": "/providers/Microsoft.Authorization/policyDefinitions/09a1f130-7697-42bc-8d84-8a9ea17e5187",
        "definitionVersion": "1.*.*",
        "policyDefinitionReferenceId": "DeployAMALinuxHybridVMWithUAIChangeTrackingAndInventory",
        "parameters": {
          "effect": {
            "value": "[parameters('effect')]"
          },
          "listOfApplicableLocations": {
            "value": "[parameters('listOfApplicableLocations')]"
          }
        }
      },
      {
        "policyDefinitionId": "/providers/Microsoft.Authorization/policyDefinitions/4bb303db-d051-4099-95d2-e3e1428a4cd5",
        "definitionVersion": "2.*.*",
        "policyDefinitionReferenceId": "DeployChangeTrackingExtensionWindowsHybridVM",
        "parameters": {
          "effect": {
            "value": "[parameters('effect')]"
          },
          "listOfApplicableLocations": {
            "value": "[parameters('listOfApplicableLocations')]"
          }
        }
      },
      {
        "policyDefinitionId": "/providers/Microsoft.Authorization/policyDefinitions/10caed8a-652c-4d1d-84e4-2805b7c07278",
        "definitionVersion": "2.*.*",
        "policyDefinitionReferenceId": "DeployChangeTrackingExtensionLinuxHybridVM",
        "parameters": {
          "effect": {
            "value": "[parameters('effect')]"
          },
          "listOfApplicableLocations": {
            "value": "[parameters('listOfApplicableLocations')]"
          }
        }
      },
      {
        "policyDefinitionId": "/providers/Microsoft.Authorization/policyDefinitions/ef9fe2ce-a588-4edd-829c-6247069dcfdb",
        "definitionVersion": "1.*.*",
        "policyDefinitionReferenceId": "DCRAWindowsHybridVMChangeTrackingAndInventory",
        "parameters": {
          "effect": {
            "value": "[parameters('effect')]"
          },
          "dcrResourceId": {
            "value": "[parameters('dcrResourceId')]"
          },
          "listOfApplicableLocations": {
            "value": "[parameters('listOfApplicableLocations')]"
          }
        }
      },
      {
        "policyDefinitionId": "/providers/Microsoft.Authorization/policyDefinitions/09a1f130-7697-42bc-8d84-8a9ea17e5192",
        "definitionVersion": "1.*.*",
        "policyDefinitionReferenceId": "DCRALinuxHybridVMChangeTrackingAndInventory",
        "parameters": {
          "effect": {
            "value": "[parameters('effect')]"
          },
          "dcrResourceId": {
            "value": "[parameters('dcrResourceId')]"
          },
          "listOfApplicableLocations": {
            "value": "[parameters('listOfApplicableLocations')]"
          }
        }
      }
    ],
    "versions": [
      "1.1.0",
      "1.0.0-PREVIEW"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policySetDefinitions/53448c70-089b-4f52-8f38-89196d7f2de1",
  "name": "53448c70-089b-4f52-8f38-89196d7f2de1"
}
Bylaw53448c70-089b-4f52-8f38-89196d7f2de1.bylaw.ps1 · 93 lines
# Converted from HybridVM.json by ConvertTo-Bylaw.
Initiative '53448c70-089b-4f52-8f38-89196d7f2de1' {

    Properties @{
        DisplayName   = 'Enable ChangeTracking and Inventory for Arc-enabled virtual machines'
        Description   = 'Enable ChangeTracking and Inventory for Arc-enabled virtual machines. Takes Data Collection Rule ID as parameter and asks for an option to input applicable locations.'
        Version       = '1.1.0'
        Category      = 'ChangeTrackingAndInventory'
        PolicyVersion = '1.1.0'
    }

    Parameter Effect @{
        AllowedValues = @('DeployIfNotExists', 'Disabled')
        Default       = 'DeployIfNotExists'
        DisplayName   = 'Effect for all constituent policies'
        Description   = 'Enable or disable the execution of each of the constituent policies in the initiative.'
    }
    Parameter DcrResourceId @{
        Type        = 'String'
        DisplayName = 'Data Collection Rule Resource Id'
        Description = 'Resource Id of the Data Collection Rule to be applied on the virtual machines in scope.'
    }
    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' }
    }

    PolicyDefinition @{
        Id          = 'a7acfae7-9497-4a3f-a3b5-a16a50abbe2f'
        ReferenceId = 'DeployAMAWindowsHybridVMWithUAIChangeTrackingAndInventory'
        Version     = '1.*.*'
        Parameters  = [ordered]@{
            effect                    = (Param Effect)
            listOfApplicableLocations = (Param ListOfApplicableLocations)
        }
    }

    PolicyDefinition @{
        Id          = '09a1f130-7697-42bc-8d84-8a9ea17e5187'
        ReferenceId = 'DeployAMALinuxHybridVMWithUAIChangeTrackingAndInventory'
        Version     = '1.*.*'
        Parameters  = [ordered]@{
            effect                    = (Param Effect)
            listOfApplicableLocations = (Param ListOfApplicableLocations)
        }
    }

    PolicyDefinition @{
        Id          = '4bb303db-d051-4099-95d2-e3e1428a4cd5'
        ReferenceId = 'DeployChangeTrackingExtensionWindowsHybridVM'
        Version     = '2.*.*'
        Parameters  = [ordered]@{
            effect                    = (Param Effect)
            listOfApplicableLocations = (Param ListOfApplicableLocations)
        }
    }

    PolicyDefinition @{
        Id          = '10caed8a-652c-4d1d-84e4-2805b7c07278'
        ReferenceId = 'DeployChangeTrackingExtensionLinuxHybridVM'
        Version     = '2.*.*'
        Parameters  = [ordered]@{
            effect                    = (Param Effect)
            listOfApplicableLocations = (Param ListOfApplicableLocations)
        }
    }

    PolicyDefinition @{
        Id          = 'ef9fe2ce-a588-4edd-829c-6247069dcfdb'
        ReferenceId = 'DCRAWindowsHybridVMChangeTrackingAndInventory'
        Version     = '1.*.*'
        Parameters  = [ordered]@{
            effect                    = (Param Effect)
            dcrResourceId             = (Param DcrResourceId)
            listOfApplicableLocations = (Param ListOfApplicableLocations)
        }
    }

    PolicyDefinition @{
        Id          = '09a1f130-7697-42bc-8d84-8a9ea17e5192'
        ReferenceId = 'DCRALinuxHybridVMChangeTrackingAndInventory'
        Version     = '1.*.*'
        Parameters  = [ordered]@{
            effect                    = (Param Effect)
            dcrResourceId             = (Param DcrResourceId)
            listOfApplicableLocations = (Param ListOfApplicableLocations)
        }
    }
}

Members (6)

Source: built-in-policies/policySetDefinitions/ChangeTrackingAndInventory/HybridVM.json in Azure/azure-policy, under the MIT licence.