title: Can I loop over properties in ARM templates?
body: <p>I have an ARM template where I set up a load balancer and I want to add a number of port openings by adding rules and probes to the LB.</p>
  
  <p>This is the template I have so far:</p>
  
  <pre><code>    {
          "type": "Microsoft.Network/loadBalancers",
          "name": "LB-front",
          "apiVersion": "2016-03-30",
          "location": "westeurope",
          "tags": { },
          "properties": {
              "frontendIPConfigurations": [
                  {
                      "name": "LoadBalancerIPConfig",
                      "properties": {
                          "privateIPAllocationMethod": "Dynamic",
                          "publicIPAddress": {
                              "id": "[resourceId('Microsoft.Network/publicIPAddresses', parameters('publicIPAddresses_lbipdev_0_name'))]"
                          }
                      }
                  }
              ],
              "backendAddressPools": [
                  {
                      "name": "LoadBalancerBEAddressPool"
                  }
              ],
              "loadBalancingRules": [
                  {
                      "name": "AppPortLBRule1",
                      "properties": {
                          "frontendIPConfiguration": {
                              "id": "[parameters('loadBalancers_LB_dev_id_6')]"
                          },
                          "frontendPort": 80,
                          "backendPort": 80,
                          "enableFloatingIP": false,
                          "idleTimeoutInMinutes": 5,
                          "protocol": "Tcp",
                          "loadDistribution": "Default",
                          "backendAddressPool": {
                              "id": "[parameters('loadBalancers_LB_dev_id_7')]"
                          },
                          "probe": {
                              "id": "[parameters('loadBalancers_LB_dev_id_8')]"
                          }
                      }
                  },
                  {
                      "name": "AppPortLBRule2",
                      "properties": {
                          "frontendIPConfiguration": {
                              "id": "[parameters('loadBalancers_LB_dev_id_9')]"
                          },
                          "frontendPort": 81,
                          "backendPort": 81,
                          "enableFloatingIP": false,
                          "idleTimeoutInMinutes": 5,
                          "protocol": "Tcp",
                          "loadDistribution": "Default",
                          "backendAddressPool": {
                              "id": "[parameters('loadBalancers_LB_dev_id_10')]"
                          },
                          "probe": {
                              "id": "[parameters('loadBalancers_LB_dev_id_11')]"
                          }
                      }
                  },
                  {
                      "name": "AppPortLBRule3",
                      "properties": {
                          "frontendIPConfiguration": {
                              "id": "[parameters('loadBalancers_LB_dev_id_12')]"
                          },
                          "frontendPort": 82,
                          "backendPort": 82,
                          "enableFloatingIP": false,
                          "idleTimeoutInMinutes": 5,
                          "protocol": "Tcp",
                          "loadDistribution": "Default",
                          "backendAddressPool": {
                              "id": "[parameters('loadBalancers_LB_dev_id_13')]"
                          },
                          "probe": {
                              "id": "[parameters('loadBalancers_LB_dev_id_14')]"
                          }
                      }
                  }
              ],
              "probes": [
                  {
                      "name": "AppPortProbe1",
                      "properties": {
                          "protocol": "Tcp",
                          "port": 80,
                          "intervalInSeconds": 5,
                          "numberOfProbes": 2
                      }
                  },
                  {
                      "name": "AppPortProbe2",
                      "properties": {
                          "protocol": "Tcp",
                          "port": 81,
                          "intervalInSeconds": 5,
                          "numberOfProbes": 2
                      }
                  },
                  {
                      "name": "AppPortProbe3",
                      "properties": {
                          "protocol": "Tcp",
                          "port": 82,
                          "intervalInSeconds": 5,
                          "numberOfProbes": 2
                      }
                  }
              ],
              "inboundNatRules": [],
              "outboundNatRules": [],
              "inboundNatPools": []
          },
          "resources": [],
          "dependsOn": [
              "[resourceId('Microsoft.Network/publicIPAddresses', parameters('publicIPAddresses_lbipdev_1_name'))]"
          ]
      },
  </code></pre>
  
  <p>(some details omitted)</p>
  
  <p>What I would like to do is to have an array of the port numbers I want to create rules and probes for and loop over those instead of explicitly having to write each rule and probe as a property for the resource.</p>
  
  <p>Basically I would like a parameter or variable in my template like this:</p>
  
  <pre><code>"ports": [ 80, 81, 82, ...]
  </code></pre>
  
  <p>and that I could loop over this similar to this: <a href="https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-create-multiple" rel="noreferrer">https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-create-multiple</a>.</p>