Created
May 16, 2025 20:34
-
-
Save levymoreira/70391779645b4c2eea6e844b0b56b4d7 to your computer and use it in GitHub Desktop.
arm template json 2 ips 1 LB
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", | |
"contentVersion": "1.0.0.0", | |
"parameters": { | |
"location": { | |
"type": "string", | |
"defaultValue": "[resourceGroup().location]", | |
"metadata": { | |
"description": "The location for all resources." | |
} | |
}, | |
"vmSize": { | |
"type": "string", | |
"defaultValue": "Standard_DS1_v2", | |
"metadata": { | |
"description": "The size of the virtual machines." | |
} | |
}, | |
"adminUsername": { | |
"type": "string", | |
"metadata": { | |
"description": "The username for the virtual machines." | |
} | |
}, | |
"adminPassword": { | |
"type": "securestring", | |
"metadata": { | |
"description": "The password for the virtual machines." | |
} | |
}, | |
"instanceCount": { | |
"type": "int", | |
"defaultValue": 2, | |
"minValue": 2, | |
"metadata": { | |
"description": "The number of virtual machine instances in the scale set." | |
} | |
}, | |
"imageOffer": { | |
"type": "string", | |
"defaultValue": "UbuntuServer", | |
"metadata": { | |
"description": "The offer for the virtual machine image." | |
} | |
}, | |
"imageSku": { | |
"type": "string", | |
"defaultValue": "18.04-LTS", | |
"metadata": { | |
"description": "The SKU for the virtual machine image." | |
} | |
}, | |
"loadBalancerNamePrefix": { | |
"type": "string", | |
"defaultValue": "web-lb", | |
"metadata": { | |
"description": "Prefix for the load balancer name" | |
} | |
}, | |
"publicIPNamePrefix": { | |
"type": "string", | |
"defaultValue": "publicip", | |
"metadata": { | |
"description": "Prefix for the public IP name" | |
} | |
} | |
}, | |
"variables": { | |
"virtualNetworkName": "web-vnet", | |
"subnetName": "web-subnet", | |
"publicIPName": "web-publicip", | |
"publicIPName2": "web-publicip2", | |
"loadBalancerName": "web-lb", | |
"nsgName": "web-nsg", | |
"loadBalancerFrontEndConfigName": "LBFrontend", | |
"loadBalancerFrontEndConfigName2": "LBFrontend2", | |
"loadBalancerBackEndPoolName": "LBBackendPool", | |
"loadBalancerProbeName": "LBProbe", | |
"loadBalancerHttpRuleName": "HTTPRule", | |
"vmssName": "web-vmss", | |
"storageAccountName": "[concat('st', uniqueString(resourceGroup().id))]", | |
"loadBalancerBackEndPoolName2": "LBBackendPool2" | |
}, | |
"resources": [ | |
{ | |
"type": "Microsoft.Storage/storageAccounts", | |
"apiVersion": "2021-04-01", | |
"name": "[variables('storageAccountName')]", | |
"location": "[parameters('location')]", | |
"sku": { | |
"name": "Standard_LRS" | |
}, | |
"kind": "Storage" | |
}, | |
{ | |
"type": "Microsoft.Network/networkSecurityGroups", | |
"apiVersion": "2020-08-01", | |
"name": "[variables('nsgName')]", | |
"location": "[parameters('location')]", | |
"properties": { | |
"securityRules": [ | |
{ | |
"name": "AllowHTTP", | |
"properties": { | |
"priority": 1000, | |
"protocol": "Tcp", | |
"access": "Allow", | |
"direction": "Inbound", | |
"sourceAddressPrefix": "*", | |
"sourcePortRange": "*", | |
"destinationAddressPrefix": "*", | |
"destinationPortRange": "80" | |
} | |
} | |
] | |
} | |
}, | |
{ | |
"type": "Microsoft.Network/publicIPAddresses", | |
"apiVersion": "2020-08-01", | |
"name": "[variables('publicIPName')]", | |
"location": "[parameters('location')]", | |
"properties": { | |
"publicIPAllocationMethod": "Static" | |
}, | |
"sku": { | |
"name": "Standard" | |
} | |
}, | |
{ | |
"type": "Microsoft.Network/publicIPAddresses", | |
"apiVersion": "2020-08-01", | |
"name": "[variables('publicIPName2')]", | |
"location": "[parameters('location')]", | |
"properties": { | |
"publicIPAllocationMethod": "Static" | |
}, | |
"sku": { | |
"name": "Standard" | |
} | |
}, | |
{ | |
"type": "Microsoft.Network/virtualNetworks", | |
"apiVersion": "2020-08-01", | |
"name": "[variables('virtualNetworkName')]", | |
"location": "[parameters('location')]", | |
"dependsOn": [ | |
"[resourceId('Microsoft.Network/networkSecurityGroups', variables('nsgName'))]" | |
], | |
"properties": { | |
"addressSpace": { | |
"addressPrefixes": [ | |
"10.0.0.0/16" | |
] | |
}, | |
"subnets": [ | |
{ | |
"name": "[variables('subnetName')]", | |
"properties": { | |
"addressPrefix": "10.0.0.0/24", | |
"networkSecurityGroup": { | |
"id": "[resourceId('Microsoft.Network/networkSecurityGroups', variables('nsgName'))]" | |
} | |
} | |
} | |
] | |
} | |
}, | |
{ | |
"type": "Microsoft.Network/loadBalancers", | |
"apiVersion": "2020-08-01", | |
"name": "[variables('loadBalancerName')]", | |
"location": "[parameters('location')]", | |
"dependsOn": [ | |
"[resourceId('Microsoft.Network/publicIPAddresses', variables('publicIPName'))]", | |
"[resourceId('Microsoft.Network/publicIPAddresses', variables('publicIPName2'))]", | |
"[resourceId('Microsoft.Network/virtualNetworks', variables('virtualNetworkName'))]" | |
], | |
"properties": { | |
"frontendIPConfigurations": [ | |
{ | |
"name": "[variables('loadBalancerFrontEndConfigName')]", | |
"properties": { | |
"publicIPAddress": { | |
"id": "[resourceId('Microsoft.Network/publicIPAddresses', variables('publicIPName'))]" | |
} | |
} | |
}, | |
{ | |
"name": "[variables('loadBalancerFrontEndConfigName2')]", | |
"properties": { | |
"publicIPAddress": { | |
"id": "[resourceId('Microsoft.Network/publicIPAddresses', variables('publicIPName2'))]" | |
} | |
} | |
} | |
], | |
"backendAddressPools": [ | |
{ | |
"name": "[variables('loadBalancerBackEndPoolName')]" | |
}, | |
{ | |
"name": "[variables('loadBalancerBackEndPoolName2')]" | |
} | |
], | |
"loadBalancingRules": [ | |
{ | |
"name": "[variables('loadBalancerHttpRuleName')]", | |
"properties": { | |
"frontendIPConfiguration": { | |
"id": "[resourceId('Microsoft.Network/loadBalancers/frontendIPConfigurations', variables('loadBalancerName'), variables('loadBalancerFrontEndConfigName'))]" | |
}, | |
"frontendPort": 80, | |
"backendPort": 80, | |
"protocol": "Tcp", | |
"enableFloatingIP": false, | |
"backendAddressPool": { | |
"id": "[resourceId('Microsoft.Network/loadBalancers/backendAddressPools', variables('loadBalancerName'), variables('loadBalancerBackEndPoolName'))]" | |
}, | |
"probe": { | |
"id": "[resourceId('Microsoft.Network/loadBalancers/probes', variables('loadBalancerName'), variables('loadBalancerProbeName'))]" | |
} | |
} | |
}, | |
{ | |
"name": "HttpRule2", | |
"properties": { | |
"frontendIPConfiguration": { | |
"id": "[resourceId('Microsoft.Network/loadBalancers/frontendIPConfigurations', variables('loadBalancerName'), variables('loadBalancerFrontEndConfigName2'))]" | |
}, | |
"frontendPort": 80, | |
"backendPort": 80, | |
"protocol": "Tcp", | |
"enableFloatingIP": false, | |
"backendAddressPool": { | |
"id": "[resourceId('Microsoft.Network/loadBalancers/backendAddressPools', variables('loadBalancerName'), variables('loadBalancerBackEndPoolName2'))]" | |
}, | |
"probe": { | |
"id": "[resourceId('Microsoft.Network/loadBalancers/probes', variables('loadBalancerName'), variables('loadBalancerProbeName'))]" | |
} | |
} | |
} | |
], | |
"probes": [ | |
{ | |
"name": "[variables('loadBalancerProbeName')]", | |
"properties": { | |
"protocol": "Http", | |
"port": 80, | |
"requestPath": "/", | |
"intervalInSeconds": 15, | |
"numberOfProbes": 2 | |
} | |
} | |
] | |
}, | |
"sku": { | |
"name": "Standard" | |
} | |
}, | |
{ | |
"type": "Microsoft.Compute/virtualMachineScaleSets", | |
"apiVersion": "2020-12-01", | |
"name": "[variables('vmssName')]", | |
"location": "[parameters('location')]", | |
"dependsOn": [ | |
"[resourceId('Microsoft.Network/loadBalancers', variables('loadBalancerName'))]", | |
"[resourceId('Microsoft.Network/virtualNetworks', variables('virtualNetworkName'))]" | |
], | |
"sku": { | |
"name": "[parameters('vmSize')]", | |
"capacity": "[parameters('instanceCount')]" | |
}, | |
"properties": { | |
"upgradePolicy": { | |
"mode": "Manual" | |
}, | |
"virtualMachineProfile": { | |
"osProfile": { | |
"computerNamePrefix": "vmss", | |
"adminUsername": "[parameters('adminUsername')]", | |
"adminPassword": "[parameters('adminPassword')]" | |
}, | |
"storageProfile": { | |
"osDisk": { | |
"createOption": "FromImage", | |
"managedDisk": { | |
"storageAccountType": "Standard_LRS" | |
} | |
}, | |
"imageReference": { | |
"publisher": "Canonical", | |
"offer": "[parameters('imageOffer')]", | |
"sku": "[parameters('imageSku')]", | |
"version": "latest" | |
} | |
}, | |
"networkProfile": { | |
"networkInterfaceConfigurations": [ | |
{ | |
"name": "nicConfig", | |
"properties": { | |
"primary": true, | |
"ipConfigurations": [ | |
{ | |
"name": "ipConfig", | |
"properties": { | |
"primary": true, | |
"subnet": { | |
"id": "[resourceId('Microsoft.Network/virtualNetworks/subnets', variables('virtualNetworkName'), variables('subnetName'))]" | |
}, | |
"loadBalancerBackendAddressPools": [ | |
{ | |
"id": "[resourceId('Microsoft.Network/loadBalancers/backendAddressPools', variables('loadBalancerName'), variables('loadBalancerBackEndPoolName'))]" | |
} | |
] | |
} | |
}, | |
{ | |
"name": "ipConfig2", | |
"properties": { | |
"subnet": { | |
"id": "[resourceId('Microsoft.Network/virtualNetworks/subnets', variables('virtualNetworkName'), variables('subnetName'))]" | |
}, | |
"loadBalancerBackendAddressPools": [ | |
{ | |
"id": "[resourceId('Microsoft.Network/loadBalancers/backendAddressPools', variables('loadBalancerName'), variables('loadBalancerBackEndPoolName2'))]" | |
} | |
] | |
} | |
} | |
], | |
"enableIpForwarding": true | |
} | |
} | |
] | |
}, | |
"extensionProfile": { | |
"extensions": [ | |
{ | |
"name": "InstallWebServer", | |
"properties": { | |
"publisher": "Microsoft.Azure.Extensions", | |
"type": "CustomScript", | |
"typeHandlerVersion": "2.1", | |
"autoUpgradeMinorVersion": true, | |
"settings": { | |
"commandToExecute": "apt-get update && apt-get install -y nginx && systemctl start nginx && systemctl enable nginx && echo '<html><body><h1>Hello from Azure VM Scale Set</h1><p>Server hostname: '$(hostname)'</p></body></html>' > /var/www/html/index.html && ufw allow 'Nginx HTTP'" | |
}, | |
"protectedSettings": {} | |
} | |
}, | |
{ | |
"name": "health-extension", | |
"properties": { | |
"publisher": "Microsoft.ManagedServices", | |
"type": "ApplicationHealthLinux", | |
"typeHandlerVersion": "1.0", | |
"autoUpgradeMinorVersion": true, | |
"settings": { | |
"protocol": "http", | |
"port": 80, | |
"requestPath": "/" | |
} | |
} | |
} | |
] | |
} | |
}, | |
"overprovision": true | |
} | |
} | |
], | |
"outputs": { | |
"publicIPAddress": { | |
"type": "string", | |
"value": "[reference(resourceId('Microsoft.Network/publicIPAddresses', variables('publicIPName'))).ipAddress]" | |
}, | |
"publicIPAddress2": { | |
"type": "string", | |
"value": "[reference(resourceId('Microsoft.Network/publicIPAddresses', variables('publicIPName2'))).ipAddress]" | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment