Bylaw

Gallery › Compute › Azure built-in policies

Configure Marketplace Network Virtual Appliances (NVAs) to add a MANA support tag

Converted Policy Disabled Modify Mode Indexed Version 1.4.0

Applies a tag for Marketplace NVA deployments when the NVA is using existing VM sizes. Please refer to https://aka.ms/manasupportforexistingvmfamilynva.

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

Azure Policy JSONMANAExistingVMNVASupport_Modify.json · 381 lines
{
  "properties": {
    "displayName": "Configure Marketplace Network Virtual Appliances (NVAs) to add a MANA support tag",
    "policyType": "BuiltIn",
    "mode": "Indexed",
    "description": "Applies a tag for Marketplace NVA deployments when the NVA is using existing VM sizes. Please refer to https://aka.ms/manasupportforexistingvmfamilynva.",
    "metadata": {
      "version": "1.4.0",
      "category": "Compute"
    },
    "version": "1.4.0",
    "parameters": {
      "effect": {
        "type": "String",
        "metadata": {
          "displayName": "Effect",
          "description": "The effect determines what happens when the policy rule is evaluated to match."
        },
        "allowedValues": [
          "Modify",
          "Disabled"
        ],
        "defaultValue": "Modify"
      },
      "tagValue": {
        "type": "String",
        "metadata": {
          "displayName": "Tag Value",
          "description": "The value to be added to the tag 'LegacyVMNVA' when the policy rule is matched."
        },
        "defaultValue": ""
      },
      "allowedPublishers": {
        "type": "Array",
        "metadata": {
          "displayName": "Allowed Publishers",
          "description": "List of allowed image publishers."
        },
        "defaultValue": [
          "a10networks*",
          "arista-networks",
          "asdivertissementinc1617837708654",
          "avi-networks",
          "aviatrix-systems",
          "barracudanetworks",
          "bluecat",
          "checkpoint",
          "cisco",
          "citrix",
          "cohesive",
          "daceitdbasensetrafficpulse1579892024934",
          "ergoninformatikag1581586464404",
          "f5-networks",
          "fatalsecurity1604924013537",
          "fortinet",
          "haproxy-technologies",
          "heimdall-data",
          "hillstone-networks",
          "imperva",
          "ivanti-vadc",
          "juniper-networks",
          "kemptech",
          "netapp",
          "netgate",
          "netskope",
          "nttltd",
          "paloaltonetworks",
          "pulse-secure",
          "radware",
          "riverbed",
          "silver-peak-systems",
          "sonicwall-inc",
          "sophos",
          "technicheltd1606969724100",
          "trendmicro",
          "twistlock",
          "velocloud",
          "versanetworks",
          "virtualpulsesro1607008728942",
          "vmware-inc",
          "voleatechgmbh1636966911943",
          "watchguard-technologies",
          "zscaler*"
        ]
      },
      "allowedOffers": {
        "type": "Array",
        "metadata": {
          "displayName": "Allowed Offers",
          "description": "List of allowed image offers (wildcards supported)."
        },
        "defaultValue": [
          "2021-04-16-11",
          "2022-saas*",
          "3223_edge*",
          "a10training*",
          "a10-vthunder*",
          "active_directory*",
          "ad_certificate*",
          "adcvpxfips*",
          "adm-onprem*",
          "ai-native-networking",
          "airlock-gateway*",
          "airs-flex",
          "aks-cngfw",
          "almalinux*",
          "aruba_edgeconnect*",
          "automation_test_vmseries*",
          "aviatrix*",
          "avi-vantage*",
          "avx-sec*",
          "awake-security*",
          "aws_cli*",
          "azure*",
          "barracuda*",
          "basic_datacenter*",
          "basic_linux*",
          "bluecat*",
          "calls-voip*",
          "centos*",
          "checkpoint*",
          "check-point*",
          "cisco*",
          "citrix*",
          "client-accelerator-controller",
          "cloud*",
          "cohesive*",
          "connector-appliance",
          "cortex_xsoar",
          "cp_saas*",
          "cpcgcspm",
          "cp-vwan*",
          "ctx*",
          "dace2it_public*",
          "datacenter*",
          "debian*",
          "debiasn_12*",
          "deep-security*",
          "dii_*",
          "dmf-controller*",
          "dns_server*",
          "docker*",
          "euc-appvolumes*",
          "euc-hcs*",
          "f5*",
          "fgt*",
          "filezilla*",
          "firebox*",
          "flexible-buying-program",
          "flowgateway",
          "forti*",
          "free_vpn*",
          "ftp*",
          "git*",
          "gitea_git*",
          "gogs_git*",
          "hapee*",
          "heimdall-data",
          "hmail_server*",
          "hyper_v*",
          "icecast_streaming*",
          "imperva*",
          "infinity-gw",
          "instaclustr*",
          "iperf3-server*",
          "isvalent-networking*",
          "ivanti-*",
          "jenkins_min*",
          "jenkins_windows*",
          "kem360*",
          "limux*",
          "linux*",
          "livewire-vm",
          "mediawiki_server*",
          "micetro*",
          "mine*",
          "minimal*",
          "multi-port-forward-server",
          "neo4j*",
          "net*",
          "network-security*",
          "nfs*",
          "nginx*",
          "nsx*",
          "obs*",
          "open*",
          "oracle*",
          "packer*",
          "pan*",
          "pcce_twistlock",
          "pfsense*",
          "playfab_xr*",
          "postgresql*",
          "preview*",
          "prisma*",
          "pro*",
          "prod*",
          "pulse*",
          "pureftp*",
          "radware*",
          "red*",
          "riverbed*",
          "riyoa*",
          "rocky*",
          "rusrdesk*",
          "rustdesk*",
          "saas-workshop",
          "safety-gear*",
          "secure*",
          "security-director-onprem-test",
          "sense-traffic*",
          "server*",
          "service-gateway*",
          "session-smart-networking-payg",
          "sftp*",
          "sg2",
          "sharefile*",
          "silver*",
          "sma*",
          "softether*",
          "sol-42222*",
          "sonicwall*",
          "sophos*",
          "squid*",
          "statseeker*",
          "steelapp*",
          "stp-vehicle*",
          "suse*",
          "tanzu*",
          "teamspeak*",
          "terraform*",
          "test_saas",
          "tkg-capi*",
          "tnsr*",
          "trac*",
          "trend*",
          "twistlock",
          "ubuntu*",
          "velocloud*",
          "veos-router*",
          "versa*",
          "virtual-network*",
          "virtualpulsesro1607008728942",
          "vlm-azure",
          "vm*",
          "vm-firebox*",
          "vmseries*",
          "vmware*",
          "vmx-*",
          "vns3*",
          "voip*",
          "vrealize*",
          "vsec",
          "vsrx-*",
          "vtair",
          "vthunder*",
          "vwaas-azure",
          "vwan-managed-nva",
          "waf*",
          "wamp*",
          "watchguard_firebox*",
          "web*",
          "win*",
          "xampp*",
          "xdr_xpr",
          "xenapp*",
          "zdx*",
          "zero-trust*",
          "zia*",
          "zscaler*",
          "ztna*"
        ]
      }
    },
    "policyRule": {
      "if": {
        "allOf": [
          {
            "field": "type",
            "in": [
              "Microsoft.Compute/virtualMachines",
              "Microsoft.Compute/virtualMachineScaleSets"
            ]
          },
          {
            "field": "tags['LegacyVMNVA']",
            "exists": false
          },
          {
            "anyOf": [
              {
                "allOf": [
                  {
                    "field": "type",
                    "equals": "Microsoft.Compute/virtualMachines"
                  },
                  {
                    "count": {
                      "value": "[parameters('allowedPublishers')]",
                      "name": "publisher",
                      "where": {
                        "field": "Microsoft.Compute/virtualMachines/storageProfile.imageReference.publisher",
                        "like": "[current('publisher')]"
                      }
                    },
                    "greater": 0
                  },
                  {
                    "count": {
                      "value": "[parameters('allowedOffers')]",
                      "name": "offer",
                      "where": {
                        "field": "Microsoft.Compute/virtualMachines/storageProfile.imageReference.offer",
                        "like": "[current('offer')]"
                      }
                    },
                    "greater": 0
                  }
                ]
              },
              {
                "allOf": [
                  {
                    "field": "type",
                    "equals": "Microsoft.Compute/virtualMachineScaleSets"
                  },
                  {
                    "count": {
                      "value": "[parameters('allowedPublishers')]",
                      "name": "publisher",
                      "where": {
                        "field": "Microsoft.Compute/virtualMachineScaleSets/virtualMachineProfile.storageProfile.imageReference.publisher",
                        "like": "[current('publisher')]"
                      }
                    },
                    "greater": 0
                  },
                  {
                    "count": {
                      "value": "[parameters('allowedOffers')]",
                      "name": "offer",
                      "where": {
                        "field": "Microsoft.Compute/virtualMachineScaleSets/virtualMachineProfile.storageProfile.imageReference.offer",
                        "like": "[current('offer')]"
                      }
                    },
                    "greater": 0
                  }
                ]
              }
            ]
          }
        ]
      },
      "then": {
        "effect": "[parameters('effect')]",
        "details": {
          "roleDefinitionIds": [
            "/providers/microsoft.authorization/roleDefinitions/b24988ac-6180-42a0-ab88-20f7382dd24c"
          ],
          "operations": [
            {
              "operation": "addOrReplace",
              "field": "tags['LegacyVMNVA']",
              "value": "[parameters('tagValue')]"
            }
          ]
        }
      }
    },
    "versions": [
      "1.4.0",
      "1.3.0",
      "1.2.0",
      "1.1.0",
      "1.0.0"
    ]
  },
  "id": "/providers/Microsoft.Authorization/policyDefinitions/e87a87f5-e6dd-4919-be21-abb0a4ea4630",
  "name": "e87a87f5-e6dd-4919-be21-abb0a4ea4630"
}
Bylawe87a87f5-e6dd-4919-be21-abb0a4ea4630.bylaw.ps1 · 72 lines
# Converted from MANAExistingVMNVASupport_Modify.json by ConvertTo-Bylaw.
Policy 'e87a87f5-e6dd-4919-be21-abb0a4ea4630' {

    Properties @{
        DisplayName   = 'Configure Marketplace Network Virtual Appliances (NVAs) to add a MANA support tag'
        Description   = 'Applies a tag for Marketplace NVA deployments when the NVA is using existing VM sizes. Please refer to https://aka.ms/manasupportforexistingvmfamilynva.'
        Version       = '1.4.0'
        Category      = 'Compute'
        PolicyVersion = '1.4.0'
        Mode          = 'Indexed'
    }

    Parameter Effect @{
        AllowedValues = @('Modify', 'Disabled')
        Default       = 'Modify'
        DisplayName   = 'Effect'
        Description   = 'The effect determines what happens when the policy rule is evaluated to match.'
    }
    Parameter TagValue @{
        Default     = ''
        DisplayName = 'Tag Value'
        Description = 'The value to be added to the tag ''LegacyVMNVA'' when the policy rule is matched.'
    }
    Parameter AllowedPublishers @{
        Type        = 'Array'
        Default     = @('a10networks*', 'arista-networks', 'asdivertissementinc1617837708654', 'avi-networks', 'aviatrix-systems', 'barracudanetworks', 'bluecat', 'checkpoint', 'cisco', 'citrix', 'cohesive', 'daceitdbasensetrafficpulse1579892024934', 'ergoninformatikag1581586464404', 'f5-networks', 'fatalsecurity1604924013537', 'fortinet', 'haproxy-technologies', 'heimdall-data', 'hillstone-networks', 'imperva', 'ivanti-vadc', 'juniper-networks', 'kemptech', 'netapp', 'netgate', 'netskope', 'nttltd', 'paloaltonetworks', 'pulse-secure', 'radware', 'riverbed', 'silver-peak-systems', 'sonicwall-inc', 'sophos', 'technicheltd1606969724100', 'trendmicro', 'twistlock', 'velocloud', 'versanetworks', 'virtualpulsesro1607008728942', 'vmware-inc', 'voleatechgmbh1636966911943', 'watchguard-technologies', 'zscaler*')
        DisplayName = 'Allowed Publishers'
        Description = 'List of allowed image publishers.'
    }
    Parameter AllowedOffers @{
        Type        = 'Array'
        Default     = @('2021-04-16-11', '2022-saas*', '3223_edge*', 'a10training*', 'a10-vthunder*', 'active_directory*', 'ad_certificate*', 'adcvpxfips*', 'adm-onprem*', 'ai-native-networking', 'airlock-gateway*', 'airs-flex', 'aks-cngfw', 'almalinux*', 'aruba_edgeconnect*', 'automation_test_vmseries*', 'aviatrix*', 'avi-vantage*', 'avx-sec*', 'awake-security*', 'aws_cli*', 'azure*', 'barracuda*', 'basic_datacenter*', 'basic_linux*', 'bluecat*', 'calls-voip*', 'centos*', 'checkpoint*', 'check-point*', 'cisco*', 'citrix*', 'client-accelerator-controller', 'cloud*', 'cohesive*', 'connector-appliance', 'cortex_xsoar', 'cp_saas*', 'cpcgcspm', 'cp-vwan*', 'ctx*', 'dace2it_public*', 'datacenter*', 'debian*', 'debiasn_12*', 'deep-security*', 'dii_*', 'dmf-controller*', 'dns_server*', 'docker*', 'euc-appvolumes*', 'euc-hcs*', 'f5*', 'fgt*', 'filezilla*', 'firebox*', 'flexible-buying-program', 'flowgateway', 'forti*', 'free_vpn*', 'ftp*', 'git*', 'gitea_git*', 'gogs_git*', 'hapee*', 'heimdall-data', 'hmail_server*', 'hyper_v*', 'icecast_streaming*', 'imperva*', 'infinity-gw', 'instaclustr*', 'iperf3-server*', 'isvalent-networking*', 'ivanti-*', 'jenkins_min*', 'jenkins_windows*', 'kem360*', 'limux*', 'linux*', 'livewire-vm', 'mediawiki_server*', 'micetro*', 'mine*', 'minimal*', 'multi-port-forward-server', 'neo4j*', 'net*', 'network-security*', 'nfs*', 'nginx*', 'nsx*', 'obs*', 'open*', 'oracle*', 'packer*', 'pan*', 'pcce_twistlock', 'pfsense*', 'playfab_xr*', 'postgresql*', 'preview*', 'prisma*', 'pro*', 'prod*', 'pulse*', 'pureftp*', 'radware*', 'red*', 'riverbed*', 'riyoa*', 'rocky*', 'rusrdesk*', 'rustdesk*', 'saas-workshop', 'safety-gear*', 'secure*', 'security-director-onprem-test', 'sense-traffic*', 'server*', 'service-gateway*', 'session-smart-networking-payg', 'sftp*', 'sg2', 'sharefile*', 'silver*', 'sma*', 'softether*', 'sol-42222*', 'sonicwall*', 'sophos*', 'squid*', 'statseeker*', 'steelapp*', 'stp-vehicle*', 'suse*', 'tanzu*', 'teamspeak*', 'terraform*', 'test_saas', 'tkg-capi*', 'tnsr*', 'trac*', 'trend*', 'twistlock', 'ubuntu*', 'velocloud*', 'veos-router*', 'versa*', 'virtual-network*', 'virtualpulsesro1607008728942', 'vlm-azure', 'vm*', 'vm-firebox*', 'vmseries*', 'vmware*', 'vmx-*', 'vns3*', 'voip*', 'vrealize*', 'vsec', 'vsrx-*', 'vtair', 'vthunder*', 'vwaas-azure', 'vwan-managed-nva', 'waf*', 'wamp*', 'watchguard_firebox*', 'web*', 'win*', 'xampp*', 'xdr_xpr', 'xenapp*', 'zdx*', 'zero-trust*', 'zia*', 'zscaler*', 'ztna*')
        DisplayName = 'Allowed Offers'
        Description = 'List of allowed image offers (wildcards supported).'
    }

    Resource * {

        When {
            Field type | Must -BeIn @('Microsoft.Compute/virtualMachines', 'Microsoft.Compute/virtualMachineScaleSets')
            Tag LegacyVMNVA | Must -Not -Exist
        }

        Require 'type, storageProfile.imageReference.publisher and storageProfile.imageReference.offer are as required' {
            AnyOf {
                Field type | Must -Not -Be 'Microsoft.Compute/virtualMachines' -IfPresent
                Count -Value (Param AllowedPublishers) -Name publisher -Where {
                    Field 'Microsoft.Compute/virtualMachines/storageProfile.imageReference.publisher' | Must -BeLike (Current publisher)
                } | Must -Be 0
                Count -Value (Param AllowedOffers) -Name offer -Where {
                    Field 'Microsoft.Compute/virtualMachines/storageProfile.imageReference.offer' | Must -BeLike (Current offer)
                } | Must -Be 0
            }
        }

        Require 'type, virtualMachineProfile.storageProfile.imageReference.publisher and virtualMachineProfile.storageProfile.imageReference.offer are as required' {
            AnyOf {
                Field type | Must -Not -Be 'Microsoft.Compute/virtualMachineScaleSets' -IfPresent
                Count -Value (Param AllowedPublishers) -Name publisher -Where {
                    Field 'Microsoft.Compute/virtualMachineScaleSets/virtualMachineProfile.storageProfile.imageReference.publisher' | Must -BeLike (Current publisher)
                } | Must -Be 0
                Count -Value (Param AllowedOffers) -Name offer -Where {
                    Field 'Microsoft.Compute/virtualMachineScaleSets/virtualMachineProfile.storageProfile.imageReference.offer' | Must -BeLike (Current offer)
                } | Must -Be 0
            }
        }
    }

    Modify -Role 'Contributor' -Effect (Param Effect) {
        Tag LegacyVMNVA | AddOrReplace (Param TagValue)
    }
}

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