{ "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", "contentVersion": "1.0.0.0", "parameters": { "location": { "type": "string", "defaultValue": "westus" }, "environmentPostfix": { "type": "string", "defaultValue": "qa" }, "vnetname": { "type": "string", "defaultValue": "hmrorvnetqa" }, "subnetname": { "type": "string", "defaultValue": "dmzsubnet" }, "numberOfWEBVM": { "type": "int", "defaultValue": 2, "maxValue": 5 }, "WebVMAdmin": { "type": "string" }, "websshKeyData": { "type": "string", "metadata": { "description": "SSH rsa public key file as a string." } }, "lbName": { "type": "string", "defaultValue": "hmrorlb", "metadata": { "description": "Load Balancer name" } }, "dnsNameforLBIP": { "type": "string", "defaultValue": "hmwebexlb01", "metadata": { "description": "DNS for Load Balancer IP" } }, "ipaddressrange": { "type": "string", "defaultValue": "11.0.2.0/24" } }, "variables": { "vmApiVersion": "2016-03-30", "networkApiVersion": "2016-03-30", "storageApiVersion": "2015-06-15", "vnetID": "[resourceId('Microsoft.Network/virtualNetworks', parameters('vnetname'))]", "websubnetRef": "[concat(variables('vnetID'),'/subnets/', parameters('subnetname'))]", "baseIP": "[split(parameters('ipaddressrange'), '/')[0]]", "ipValues": "[split(variables('baseIP'), '.')]", "vnetfirst2": "[concat(variables('ipValues')[0], '.', variables('ipValues')[1], '.')]", "subnetFirst3": "[concat(variables('vnetfirst2'), variables('ipValues')[2])]", "ip1": "[concat(variables('subnetFirst3'), '.', add(int(variables('ipValues')[3]), 4))]", "ip2": "[concat(variables('subnetFirst3'), '.', add(int(variables('ipValues')[3]), 5))]", "ip3": "[concat(variables('subnetFirst3'), '.', add(int(variables('ipValues')[3]), 6))]", "fileUris": "https://raw.githubusercontent.com/srakesh28/azure-ubuntu-ror-postgress/master/install_ruby.sh", "commandToExecute": "sh install_ruby.sh", "addresses": [ "[variables('ip1')]", "[variables('ip2')]", "[variables('ip3')]" ], "remoteNodeIPArray": ["0.0.0.0", "1.1.1.1", "2.2.2.2"], "alladdresses": "[concat(variables('addresses'), variables('remoteNodeIPArray'))]", "storageAccountType": "Standard_LRS", "webVmSize": "Standard_D2_V2", "as_web": "[concat(variables('webprefix'), 'as', parameters('environmentPostfix'))]", "webprefix": "web", "vmname": "[concat(variables('webprefix'), 'vm', parameters('environmentPostfix'))]", "webStorageAccount": "[concat(substring(uniqueString(resourceGroup().id, variables('vmname')),5), variables('webprefix'), 'sa')]", "webdiagnosticsStorageAccount": "[concat(substring(uniqueString(resourceGroup().id, variables('vmname')),5), variables('webprefix'), 'diagsa')]", "websshKeyPath": "[concat('/home/',parameters('WebVMAdmin'),'/.ssh/authorized_keys')]", "publicIPAddressType": "Dynamic", "publicIPAddressID": "[resourceId('Microsoft.Network/publicIPAddresses',parameters('dnsNameforLBIP'))]", "lbID": "[resourceId('Microsoft.Network/loadBalancers',parameters('lbName'))]", "frontEndIPConfigID": "[concat(variables('lbID'),'/frontendIPConfigurations/LoadBalancerFrontEnd')]", "lbPoolID": "[concat(variables('lbID'),'/backendAddressPools/BackendPool1')]", "lbProbeID": "[concat(variables('lbID'),'/probes/tcpProbe')]", "lbProbeID2": "[concat(variables('lbID'),'/probes/tcpProbehttps')]", "imageReferences": { "web": { "publisher": "Canonical", "offer": "UbuntuServer", "sku": "14.04.2-LTS", "version": "latest" } } }, "resources": [{ "type": "Microsoft.Storage/storageAccounts", "name": "[concat(variables('webstorageaccount'), copyIndex())]", "apiVersion": "[variables('storageApiVersion')]", "location": "[parameters('location')]", "tags": { "displayName": "webstorageaccounts" }, "copy": { "name": "webStorageLoop", "count": "[parameters('numberOfWEBVM')]" }, "properties": { "accountType": "[variables('storageAccountType')]" } }, { "type": "Microsoft.Storage/storageAccounts", "name": "[variables('webdiagnosticsStorageAccount')]", "apiVersion": "[variables('storageApiVersion')]", "location": "[parameters('location')]", "tags": { "displayName": "webdiagnosticstorage" }, "properties": { "accountType": "Standard_LRS" } }, { "type": "Microsoft.Compute/availabilitySets", "name": "[variables('as_web')]", "apiVersion": "[variables('vmApiVersion')]", "location": "[parameters('location')]", "properties": { "platformUpdateDomainCount": 6, "platformFaultDomainCount": 3 }, "tags": { "displayName": "availabilityset_web" }, "dependsOn": [] }, { "apiVersion": "[variables('vmApiVersion')]", "type": "Microsoft.Compute/virtualMachines", "name": "[concat(variables('vmname'), copyIndex())]", "location": "[parameters('location')]", "copy": { "name": "webvmLoop", "count": "[parameters('numberOfWEBVM')]" }, "tags": { "displayName": "webvms" }, "dependsOn": [ "webStorageLoop", "[resourceId('Microsoft.Compute/availabilitySets', variables('as_web'))]", "[concat('Microsoft.Network/networkInterfaces/', variables('vmname'),'nic', copyindex())]" ], "properties": { "availabilitySet": { "id": "[resourceId('Microsoft.Compute/availabilitySets', variables('as_web'))]" }, "hardwareProfile": { "vmSize": "[variables('webVmSize')]" }, "osProfile": { "computerName": "[concat(variables('vmname'),copyIndex())]", "adminUsername": "[parameters('WebVMAdmin')]", "linuxConfiguration": { "disablePasswordAuthentication": true, "ssh": { "publicKeys": [{ "path": "[variables('websshKeyPath')]", "keyData": "[parameters('websshKeyData')]" }] } } }, "storageProfile": { "imageReference": "[variables('imagereferences').web]", "osDisk": { "name": "webosdisk", "vhd": { "uri": "[concat('http://',variables('webStorageAccount'), copyIndex(),'.blob.core.windows.net/vhds/','webosdisk', copyIndex(), '.vhd')]" }, "caching": "ReadWrite", "createOption": "FromImage" } }, "networkProfile": { "networkInterfaces": [{ "id": "[resourceId('Microsoft.Network/networkInterfaces',concat(variables('vmname'),'nic', copyindex()))]" }] } } }, { "type": "Microsoft.Compute/virtualMachines/extensions", "name": "[concat(variables('vmname'), copyIndex(), '/install_ruby')]", "apiVersion": "[variables('vmApiVersion')]", "location": "[parameters('location')]", "dependsOn": [ "webvmLoop" ], "copy": { "name": "scriptCopyLoop", "count": "[parameters('numberOfWEBVM')]" }, "tags": { "displayName": "webvmscript" }, "properties": { "publisher": "Microsoft.Azure.Extensions", "type": "CustomScript", "typeHandlerVersion": "2.0", "autoUpgradeMinorVersion": true, "settings": { "fileUris": [ "https://raw.githubusercontent.com/srakesh28/azure-ubuntu-ror-postgress/master/install_ruby.sh" ], "commandToExecute": "sh install_ruby.sh" } } }, { "type": "Microsoft.Compute/virtualMachines/extensions", "name": "[concat(variables('vmname'), copyIndex(), '/diagext')]", "apiVersion": "[variables('vmApiVersion')]", "location": "[parameters('location')]", "dependsOn": [ "webvmLoop" ], "copy": { "name": "webvmdiagextensionLoop", "count": "[parameters('numberOfWEBVM')]" }, "tags": { "displayName": "webvmsdiagext" }, "properties": { "publisher": "Microsoft.OSTCExtensions", "type": "LinuxDiagnostic", "typeHandlerVersion": "2.3", "autoUpgradeMinorVersion": true, "settings": { "perfCfg": [{ "query": "SELECT UsedMemory,AvailableMemory FROM SCX_MemoryStatisticalInformation", "table": "Memory" }, { "query": "SELECT PercentProcessorTime FROM SCX_ProcessorStatisticalInformation", "table": "_Total" }] }, "protectedSettings": { "storageAccountName": "[variables('webdiagnosticsStorageAccount')]", "storageAccountKey": "[listkeys(variables('webdiagnosticsStorageAccount'), variables('storageApiVersion')).key1]", "storageAccountEndPoint": "https://core.windows.net" } } }, { "apiVersion": "[variables('vmApiVersion')]", "type": "Microsoft.Network/networkInterfaces", "name": "[concat(variables('vmname'),'nic', copyindex())]", "location": "[parameters('location')]", "copy": { "name": "webnicLoop", "count": "[parameters('numberOfWEBVM')]" }, "dependsOn": [ "[concat('Microsoft.Network/loadBalancers/', parameters('lbName'))]" ], "tags": { "displayName": "webNICs" }, "properties": { "ipConfigurations": [ { "name": "ipconfig1", "properties": { "privateIPAllocationMethod": "Dynamic", "subnet": { "id": "[variables('websubnetRef')]" }, "loadBalancerBackendAddressPools": [ { "id": "[concat(variables('lbID'), '/backendAddressPools/BackendPool1')]" } ] } } ] } }, { "apiVersion": "[variables('vmApiVersion')]", "type": "Microsoft.Network/publicIPAddresses", "name": "[parameters('dnsNameforLBIP')]", "location": "[resourceGroup().location]", "properties": { "publicIPAllocationMethod": "[variables('publicIPAddressType')]", "dnsSettings": { "domainNameLabel": "[parameters('dnsNameforLBIP')]" } } }, { "apiVersion": "[variables('vmApiVersion')]", "name": "[parameters('lbName')]", "type": "Microsoft.Network/loadBalancers", "location": "[resourceGroup().location]", "dependsOn": [ "[concat('Microsoft.Network/publicIPAddresses/', parameters('dnsNameforLBIP'))]" ], "properties": { "frontendIPConfigurations": [ { "name": "LoadBalancerFrontEnd", "properties": { "publicIPAddress": { "id": "[variables('publicIPAddressID')]" } } } ], "backendAddressPools": [ { "name": "BackendPool1" } ], "loadBalancingRules": [ { "name": "LBRulehttp", "properties": { "frontendIPConfiguration": { "id": "[variables('frontEndIPConfigID')]" }, "backendAddressPool": { "id": "[variables('lbPoolID')]" }, "protocol": "tcp", "frontendPort": 80, "backendPort": 80, "enableFloatingIP": false, "idleTimeoutInMinutes": 5, "probe": { "id": "[variables('lbProbeID')]" } } }, { "name": "LBRulehttps", "properties": { "frontendIPConfiguration": { "id": "[variables('frontEndIPConfigID')]" }, "backendAddressPool": { "id": "[variables('lbPoolID')]" }, "protocol": "tcp", "frontendPort": 443, "backendPort": 443, "enableFloatingIP": false, "idleTimeoutInMinutes": 5, "probe": { "id": "[variables('lbProbeID2')]" } } } ], "probes": [ { "name": "tcpProbe", "properties": { "protocol": "tcp", "port": 80, "intervalInSeconds": 5, "numberOfProbes": 2 } }, { "name": "tcpProbehttps", "properties": { "protocol": "tcp", "port": 443, "intervalInSeconds": 5, "numberOfProbes": 2 } } ] } } ], "outputs": { "LBAddress": { "type": "array", "value": "[variables('addresses')]" } } }