Created
August 14, 2018 12:41
-
-
Save zhantong/c5d0d2b3db9bf5e9dc98034f434c6c29 to your computer and use it in GitHub Desktop.
Azure VM with IPv6 by load balancer
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": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json", | |
| "contentVersion": "1.0.0.0", | |
| "parameters": { | |
| "adminUsername": { | |
| "type": "string", | |
| "metadata": { | |
| "description": "Admin username" | |
| } | |
| }, | |
| "adminPassword": { | |
| "type": "securestring", | |
| "metadata": { | |
| "description": "Admin password" | |
| } | |
| }, | |
| "dnsNameforIPv4LbIP": { | |
| "type": "string", | |
| "metadata": { | |
| "description": "DNS prefix for IPv4 IP Address of the load balancer. It must be lowercase and match the regex: ^[a-z][a-z0-9-]{1,61}[a-z0-9]$." | |
| } | |
| }, | |
| "dnsNameforIPv6LbIP": { | |
| "type": "string", | |
| "metadata": { | |
| "description": "DNS prefix for IPv6 IP Address of the load balancer. It must be lowercase and match the regex: ^[a-z][a-z0-9-]{1,61}[a-z0-9]$." | |
| } | |
| } | |
| }, | |
| "variables": { | |
| "vmNamePrefix": "myIPv6VM", | |
| "nicNamePrefix": "IPv6Nic", | |
| "availabilitySetName": "myIPv6AvSet", | |
| "addressPrefix": "10.0.0.0/16", | |
| "subnetName": "myIPv4Subnet", | |
| "subnetPrefix": "10.0.0.0/24", | |
| "vnetName": "myIPv4VNet", | |
| "ipv4PrivateIPAddressType": "Dynamic", | |
| "ipv6PrivateIPAddressType": "Dynamic", | |
| "numberOfInstances": 1, | |
| "ipv6PublicIPAddressName": "myIPv6PublicIP", | |
| "ipv4PublicIPAddressName": "myIPv4PublicIP", | |
| "ipv4PublicIPAddressType": "Static", | |
| "ipv6PublicIPAddressType": "Dynamic", | |
| "lbName": "myIPv4IPv6LB", | |
| "lbID": "[resourceId('Microsoft.Network/loadBalancers',variables('lbName'))]", | |
| "ipv4FrontEndIPConfigID": "[concat(variables('lbID'),'/frontendIPConfigurations/LoadBalancerFrontEndIPv4')]", | |
| "ipv6FrontEndIPConfigID": "[concat(variables('lbID'),'/frontendIPConfigurations/LoadBalancerFrontEndIPv6')]", | |
| "ipv4LbBackendPoolID": "[concat(variables('lbID'),'/backendAddressPools/BackendPoolIPv4')]", | |
| "ipv6LbBackendPoolID": "[concat(variables('lbID'),'/backendAddressPools/BackendPoolIPv6')]", | |
| "ipv4ipv6lbProbeName": "tcpProbeIPv4IPv6", | |
| "ipv4ipv6lbProbeID": "[concat(variables('lbID'),'/probes/', variables('ipv4ipv6lbProbeName'))]" | |
| }, | |
| "resources": [ | |
| { | |
| "type": "Microsoft.Compute/availabilitySets", | |
| "name": "[variables('availabilitySetName')]", | |
| "apiVersion": "2016-04-30-preview", | |
| "location": "[resourceGroup().location]", | |
| "properties": { | |
| "platformFaultDomainCount": 2, | |
| "platformUpdateDomainCount": 2, | |
| "managed": true | |
| } | |
| }, | |
| { | |
| "apiVersion": "2016-03-30", | |
| "type": "Microsoft.Network/publicIPAddresses", | |
| "name": "[variables('ipv4PublicIPAddressName')]", | |
| "location": "[resourceGroup().location]", | |
| "properties": { | |
| "publicIPAddressVersion": "IPv4", | |
| "publicIPAllocationMethod": "[variables('ipv4PublicIPAddressType')]", | |
| "dnsSettings": { | |
| "domainNameLabel": "[parameters('dnsNameforIPv4LbIP')]" | |
| } | |
| } | |
| }, | |
| { | |
| "apiVersion": "2016-03-30", | |
| "type": "Microsoft.Network/publicIPAddresses", | |
| "name": "[variables('ipv6PublicIPAddressName')]", | |
| "location": "[resourceGroup().location]", | |
| "properties": { | |
| "publicIPAddressVersion": "IPv6", | |
| "publicIPAllocationMethod": "[variables('ipv6PublicIPAddressType')]", | |
| "dnsSettings": { | |
| "domainNameLabel": "[parameters('dnsNameforIPv6LbIP')]" | |
| } | |
| } | |
| }, | |
| { | |
| "apiVersion": "2016-03-30", | |
| "type": "Microsoft.Network/virtualNetworks", | |
| "name": "[variables('vnetName')]", | |
| "location": "[resourceGroup().location]", | |
| "properties": { | |
| "addressSpace": { | |
| "addressPrefixes": [ | |
| "[variables('addressPrefix')]" | |
| ] | |
| }, | |
| "subnets": [ | |
| { | |
| "name": "[variables('subnetName')]", | |
| "properties": { | |
| "addressPrefix": "[variables('subnetPrefix')]" | |
| } | |
| } | |
| ] | |
| } | |
| }, | |
| { | |
| "apiVersion": "2018-01-01", | |
| "type": "Microsoft.Network/networkInterfaces", | |
| "name": "[concat(variables('nicNamePrefix'), copyindex())]", | |
| "location": "[resourceGroup().location]", | |
| "copy": { | |
| "name": "nicLoop", | |
| "count": "[variables('numberOfInstances')]" | |
| }, | |
| "dependsOn": [ | |
| "[concat('Microsoft.Network/virtualNetworks/', variables('vnetName'))]", | |
| "[concat('Microsoft.Network/loadBalancers/', variables('lbName'))]" | |
| ], | |
| "properties": { | |
| "ipConfigurations": [ | |
| { | |
| "name": "ipv4IPConfig", | |
| "properties": { | |
| "privateIPAddressVersion": "IPv4", | |
| "privateIPAllocationMethod": "[variables('ipv4PrivateIPAddressType')]", | |
| "subnet": { | |
| "id": "[resourceId('Microsoft.Network/virtualNetworks/subnets',variables('vnetName'), variables('subnetName'))]" | |
| }, | |
| "loadBalancerBackendAddressPools": [ | |
| { | |
| "id": "[variables('ipv4LbBackendPoolID')]" | |
| } | |
| ], | |
| "loadBalancerInboundNatRules": [ | |
| { | |
| "id": "[concat(variables('lbID'),'/inboundNatRules/RDP-VM', copyindex())]" | |
| } | |
| ] | |
| } | |
| }, | |
| { | |
| "name": "ipv6IPConfig", | |
| "properties": { | |
| "privateIPAddressVersion": "IPv6", | |
| "privateIPAllocationMethod": "[variables('ipv6PrivateIPAddressType')]", | |
| "loadBalancerBackendAddressPools": [ | |
| { | |
| "id": "[variables('ipv6LbBackendPoolID')]" | |
| } | |
| ] | |
| } | |
| } | |
| ] | |
| } | |
| }, | |
| { | |
| "apiVersion": "2016-03-30", | |
| "name": "[variables('lbName')]", | |
| "type": "Microsoft.Network/loadBalancers", | |
| "location": "[resourceGroup().location]", | |
| "dependsOn": [ | |
| "[concat('Microsoft.Network/publicIPAddresses/', variables('ipv4PublicIPAddressName'))]", | |
| "[concat('Microsoft.Network/publicIPAddresses/', variables('ipv6PublicIPAddressName'))]" | |
| ], | |
| "properties": { | |
| "frontendIPConfigurations": [ | |
| { | |
| "name": "LoadBalancerFrontEndIPv4", | |
| "properties": { | |
| "publicIPAddress": { | |
| "id": "[resourceId('Microsoft.Network/publicIPAddresses',variables('ipv4PublicIPAddressName'))]" | |
| } | |
| } | |
| }, | |
| { | |
| "name": "LoadBalancerFrontEndIPv6", | |
| "properties": { | |
| "publicIPAddress": { | |
| "id": "[resourceId('Microsoft.Network/publicIPAddresses',variables('ipv6PublicIPAddressName'))]" | |
| } | |
| } | |
| } | |
| ], | |
| "backendAddressPools": [ | |
| { | |
| "name": "BackendPoolIPv4" | |
| }, | |
| { | |
| "name": "BackendPoolIPv6" | |
| } | |
| ], | |
| "inboundNatRules": [ | |
| { | |
| "name": "RDP-VM0", | |
| "properties": { | |
| "frontendIPConfiguration": { | |
| "id": "[variables('ipv4FrontEndIPConfigID')]" | |
| }, | |
| "protocol": "tcp", | |
| "frontendPort": 50001, | |
| "backendPort": 22, | |
| "enableFloatingIP": false | |
| } | |
| } | |
| ], | |
| "loadBalancingRules": [ | |
| { | |
| "name": "LBRuleIPv4", | |
| "properties": { | |
| "frontendIPConfiguration": { | |
| "id": "[variables('ipv4FrontEndIPConfigID')]" | |
| }, | |
| "backendAddressPool": { | |
| "id": "[variables('ipv4LbBackendPoolID')]" | |
| }, | |
| "protocol": "Tcp", | |
| "frontendPort": 80, | |
| "backendPort": 80, | |
| "enableFloatingIP": false, | |
| "idleTimeoutInMinutes": 5, | |
| "probe": { | |
| "id": "[variables('ipv4ipv6lbProbeID')]" | |
| } | |
| } | |
| }, | |
| { | |
| "name": "LBRuleIPv6", | |
| "properties": { | |
| "frontendIPConfiguration": { | |
| "id": "[variables('ipv6FrontEndIPConfigID')]" | |
| }, | |
| "backendAddressPool": { | |
| "id": "[variables('ipv6LbBackendPoolID')]" | |
| }, | |
| "protocol": "Tcp", | |
| "frontendPort": 80, | |
| "backendPort": 8080, | |
| "probe": { | |
| "id": "[variables('ipv4ipv6lbProbeID')]" | |
| } | |
| } | |
| } | |
| ], | |
| "probes": [ | |
| { | |
| "name": "[variables('ipv4ipv6lbProbeName')]", | |
| "properties": { | |
| "protocol": "Tcp", | |
| "port": 80, | |
| "intervalInSeconds": 5, | |
| "numberOfProbes": 2 | |
| } | |
| } | |
| ] | |
| } | |
| }, | |
| { | |
| "apiVersion": "2016-04-30-preview", | |
| "type": "Microsoft.Compute/virtualMachines", | |
| "name": "[concat(variables('vmNamePrefix'), copyindex())]", | |
| "copy": { | |
| "name": "virtualMachineLoop", | |
| "count": "[variables('numberOfInstances')]" | |
| }, | |
| "location": "[resourceGroup().location]", | |
| "dependsOn": [ | |
| "[concat('Microsoft.Network/networkInterfaces/', variables('nicNamePrefix'), copyindex())]", | |
| "[concat('Microsoft.Compute/availabilitySets/', variables('availabilitySetName'))]" | |
| ], | |
| "properties": { | |
| "availabilitySet": { | |
| "id": "[resourceId('Microsoft.Compute/availabilitySets',variables('availabilitySetName'))]" | |
| }, | |
| "hardwareProfile": { | |
| "vmSize": "Standard_B1s" | |
| }, | |
| "osProfile": { | |
| "computerName": "[concat(variables('vmNamePrefix'), copyIndex())]", | |
| "adminUsername": "[parameters('adminUsername')]", | |
| "adminPassword": "[parameters('adminPassword')]" | |
| }, | |
| "storageProfile": { | |
| "imageReference": { | |
| "publisher": "Canonical", | |
| "offer": "UbuntuServer", | |
| "sku": "18.04-LTS", | |
| "version": "latest" | |
| }, | |
| "osDisk": { | |
| "createOption": "FromImage" | |
| } | |
| }, | |
| "networkProfile": { | |
| "networkInterfaces": [ | |
| { | |
| "id": "[resourceId('Microsoft.Network/networkInterfaces',concat(variables('nicNamePrefix'),copyindex()))]" | |
| } | |
| ] | |
| } | |
| } | |
| } | |
| ] | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You should go to Load Balancer settings and add new inbound rule if you want to open new port.