Skip to content

Instantly share code, notes, and snippets.

@ajomathew
Created September 30, 2021 01:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ajomathew/88ce62b3eb21f3f54c94365ce0ad9c70 to your computer and use it in GitHub Desktop.
Save ajomathew/88ce62b3eb21f3f54c94365ce0ad9c70 to your computer and use it in GitHub Desktop.
Azure ARM template with multiple copy properties
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"location": {
"type": "string"
},
"applicationGatewayName": {
"type": "string"
},
"tier": {
"type": "string"
},
"skuSize": {
"type": "string"
},
"capacity": {
"type": "int",
"defaultValue": 2
},
"subnetName": {
"type": "string"
},
"zones": {
"type": "array"
},
"virtualNetworkName": {
"type": "string"
},
"virtualNetworkPrefix": {
"type": "array"
},
"publicIpAddressName": {
"type": "string"
},
"sku": {
"type": "string"
},
"allocationMethod": {
"type": "string"
},
"publicIpZones": {
"type": "array"
},
"privateIpAddress": {
"type": "string"
},
"backend": {
"type": "array"
},
"frontendPortsAvailable": {
"type": "object"
},
"backendHttpSettingsCollection": {
"type": "object"
}
},
"variables": {
"vnetId": "[resourceId('Microsoft.Network/virtualNetworks/', parameters('virtualNetworkName'))]",
"publicIPRef": "[resourceId('Microsoft.Network/publicIPAddresses/', parameters('publicIpAddressName'))]",
"subnetRef": "[concat(variables('vnetId'), '/subnets/', parameters('subnetName'))]",
"applicationGatewayId": "[resourceId('Microsoft.Network/applicationGateways', parameters('applicationGatewayName'))]"
},
"resources": [
{
"name": "[parameters('applicationGatewayName')]",
"type": "Microsoft.Network/applicationGateways",
"apiVersion": "2019-09-01",
"location": "[parameters('location')]",
"zones": "[parameters('zones')]",
"dependsOn": [
"[concat('Microsoft.Network/virtualNetworks/', parameters('virtualNetworkName'))]",
"[concat('Microsoft.Network/publicIPAddresses/', parameters('publicIpAddressName'))]"
],
"tags": {},
"properties": {
"sku": {
"name": "[parameters('skuSize')]",
"tier": "[parameters('tier')]",
"capacity": "[parameters('capacity')]"
},
"gatewayIPConfigurations": [
{
"name": "appGatewayIpConfig",
"properties": {
"subnet": {
"id": "[variables('subnetRef')]"
}
}
}
],
"frontendIPConfigurations": [
{
"name": "appGwPublicFrontendIp",
"properties": {
"PublicIPAddress": {
"id": "[variables('publicIPRef')]"
}
}
},
{
"name": "appGwPrivateFrontendIp",
"properties": {
"subnet": {
"id": "[variables('subnetRef')]"
},
"privateIPAddress": "[parameters('privateIpAddress')]",
"privateIPAllocationMethod": "Static"
}
}
],
"copy": [
{
"name": "frontendPorts",
"count": "[length(parameters('frontendPortsAvailable').frontendPorts)]",
"input": {
"name": "[parameters('frontendPortsAvailable').frontendPorts[copyIndex('frontendPorts')].name]",
"properties": {
"Port": "[parameters('frontendPortsAvailable').frontendPorts[copyIndex('frontendPorts')].Port]"
}
}
},
{
"name": "backendHttpSettingsCollection",
"count": "[length(parameters('backendHttpSettingsCollection').backendHttpSettings)]",
"input": {
"name": "[parameters('backendHttpSettingsCollection').backendHttpSettings[copyIndex('backendHttpSettingsCollection')].name]",
"properties": {
"Port": "[parameters('backendHttpSettingsCollection').backendHttpSettings[copyIndex('backendHttpSettingsCollection')].port]",
"Protocol": "[parameters('backendHttpSettingsCollection').backendHttpSettings[copyIndex('backendHttpSettingsCollection')].Protocol]",
"cookieBasedAffinity": "[parameters('backendHttpSettingsCollection').backendHttpSettings[copyIndex('backendHttpSettingsCollection')].cookieBasedAffinity]",
"requestTimeout": "[parameters('backendHttpSettingsCollection').backendHttpSettings[copyIndex('backendHttpSettingsCollection')].requestTimeout]"
}
}
}
],
"backendAddressPools": [
{
"name": "my_test_backendpool",
"properties": {
"backendAddresses": [
{ "fqdn": "Test.abc" }
]
}
}
],
"httpListeners": [
{
"name": "my_test_listner",
"properties": {
"frontendIPConfiguration": {
"id": "[concat(variables('applicationGatewayId'), '/frontendIPConfigurations/appGwPrivateFrontendIp')]"
},
"frontendPort": {
"id": "[concat(variables('applicationGatewayId'), '/frontendPorts/port_80')]"
},
"protocol": "Http",
"sslCertificate": null
}
}
],
"requestRoutingRules": [
{
"Name": "my_test_reqrouterules",
"properties": {
"RuleType": "Basic",
"httpListener": {
"id": "[concat(variables('applicationGatewayId'), '/httpListeners/my_test_listner')]"
},
"priority": null,
"backendAddressPool": {
"id": "[concat(variables('applicationGatewayId'), '/backendAddressPools/my_test_backendpool')]"
},
"backendHttpSettings": {
"id": "[concat(variables('applicationGatewayId'), '/backendHttpSettingsCollection/http_80Settings')]"
}
}
}
],
"enableHttp2": false,
"sslCertificates": [],
"probes": []
}
},
{
"apiVersion": "2019-09-01",
"type": "Microsoft.Network/virtualNetworks",
"name": "[parameters('virtualNetworkName')]",
"location": "[parameters('location')]",
"properties": {
"addressSpace": {
"addressPrefixes": "[parameters('virtualNetworkPrefix')]"
},
"subnets": [
{
"name": "default",
"properties": {
"addressPrefix": "10.0.0.0/24"
}
}
]
}
},
{
"apiVersion": "2020-08-01",
"type": "Microsoft.Network/publicIPAddresses",
"name": "[parameters('publicIpAddressName')]",
"location": "[parameters('location')]",
"sku": {
"name": "[parameters('sku')]"
},
"zones": "[parameters('publicIpZones')]",
"properties": {
"publicIPAllocationMethod": "[parameters('allocationMethod')]"
}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment