{ "$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" }, "numberOfsidekiqVM": { "type": "int", "defaultValue": 1, "maxValue": 5 }, "sidekiqVMAdmin": { "type": "string" }, "sidekiqsshKeyData": { "type": "string", "metadata": { "description": "SSH rsa public key file as a string." } }, "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'))]", "sidekiqsubnetRef": "[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_sidekiq.sh", "commandToExecute": "sh install_sidekiq.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", "sidekiqVmSize": "Standard_D2_V2", "as_sidekiq": "[concat(variables('sidekiqprefix'), 'as', parameters('environmentPostfix'))]", "sidekiqprefix": "sidekiq", "vmname": "[concat(variables('sidekiqprefix'), 'vm', parameters('environmentPostfix'))]", "sidekiqStorageAccount": "[concat(substring(uniqueString(resourceGroup().id, variables('vmname')),5), variables('sidekiqprefix'), 'sa')]", "sidekiqdiagnosticsStorageAccount": "[concat(substring(uniqueString(resourceGroup().id, variables('vmname')),5), variables('sidekiqprefix'), 'diagsa')]", "sidekiqsshKeyPath": "[concat('/home/',parameters('sidekiqVMAdmin'),'/.ssh/authorized_keys')]", "imageReferences": { "sidekiq": { "publisher": "Canonical", "offer": "UbuntuServer", "sku": "14.04.2-LTS", "version": "latest" } } }, "resources": [{ "type": "Microsoft.Storage/storageAccounts", "name": "[concat(variables('sidekiqstorageaccount'), copyIndex())]", "apiVersion": "[variables('storageApiVersion')]", "location": "[parameters('location')]", "tags": { "displayName": "sidekiqstorageaccounts" }, "copy": { "name": "sidekiqStorageLoop", "count": "[parameters('numberOfsidekiqVM')]" }, "properties": { "accountType": "[variables('storageAccountType')]" } }, { "type": "Microsoft.Storage/storageAccounts", "name": "[variables('sidekiqdiagnosticsStorageAccount')]", "apiVersion": "[variables('storageApiVersion')]", "location": "[parameters('location')]", "tags": { "displayName": "sidekiqdiagnosticstorage" }, "properties": { "accountType": "Standard_LRS" } }, { "type": "Microsoft.Compute/availabilitySets", "name": "[variables('as_sidekiq')]", "apiVersion": "[variables('vmApiVersion')]", "location": "[parameters('location')]", "properties": { "platformUpdateDomainCount": 6, "platformFaultDomainCount": 3 }, "tags": { "displayName": "availabilityset_sidekiq" }, "dependsOn": [] }, { "apiVersion": "[variables('vmApiVersion')]", "type": "Microsoft.Compute/virtualMachines", "name": "[concat(variables('vmname'), copyIndex())]", "location": "[parameters('location')]", "copy": { "name": "sidekiqvmLoop", "count": "[parameters('numberOfsidekiqVM')]" }, "tags": { "displayName": "sidekiqvms" }, "dependsOn": [ "sidekiqStorageLoop", "[resourceId('Microsoft.Compute/availabilitySets', variables('as_sidekiq'))]", "[concat('Microsoft.Network/networkInterfaces/', variables('vmname'),'nic', copyindex())]" ], "properties": { "availabilitySet": { "id": "[resourceId('Microsoft.Compute/availabilitySets', variables('as_sidekiq'))]" }, "hardwareProfile": { "vmSize": "[variables('sidekiqVmSize')]" }, "osProfile": { "computerName": "[concat(variables('vmname'),copyIndex())]", "adminUsername": "[parameters('sidekiqVMAdmin')]", "linuxConfiguration": { "disablePasswordAuthentication": true, "ssh": { "publicKeys": [{ "path": "[variables('sidekiqsshKeyPath')]", "keyData": "[parameters('sidekiqsshKeyData')]" }] } } }, "storageProfile": { "imageReference": "[variables('imagereferences').sidekiq]", "osDisk": { "name": "sidekiqosdisk", "vhd": { "uri": "[concat('http://',variables('sidekiqStorageAccount'), copyIndex(),'.blob.core.windows.net/vhds/','sidekiqosdisk', 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": [ "sidekiqvmLoop" ], "copy": { "name": "scriptCopyLoop", "count": "[parameters('numberOfsidekiqVM')]" }, "tags": { "displayName": "sidekiqvmscript" }, "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_sidekiq.sh" ], "commandToExecute": "sh install_sidekiq.sh" } } }, { "type": "Microsoft.Compute/virtualMachines/extensions", "name": "[concat(variables('vmname'), copyIndex(), '/diagext')]", "apiVersion": "[variables('vmApiVersion')]", "location": "[parameters('location')]", "dependsOn": [ "sidekiqvmLoop" ], "copy": { "name": "sidekiqvmdiagextensionLoop", "count": "[parameters('numberOfsidekiqVM')]" }, "tags": { "displayName": "sidekiqvmsdiagext" }, "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('sidekiqdiagnosticsStorageAccount')]", "storageAccountKey": "[listkeys(variables('sidekiqdiagnosticsStorageAccount'), 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": "sidekiqnicLoop", "count": "[parameters('numberOfsidekiqVM')]" }, "dependsOn": [], "tags": { "displayName": "sidekiqNICs" }, "properties": { "ipConfigurations": [{ "name": "ipconfigsidekiq", "properties": { "privateIPAllocationMethod": "Static", "privateIPAddress": "[variables('addresses')[copyIndex()]]", "subnet": { "id": "[variables('sidekiqsubnetRef')]" } } }] } } ], "outputs": { "LBAddress": { "type": "array", "value": "[variables('addresses')]" } } }