Created
October 13, 2015 20:55
-
-
Save shirhatti/c29056fab702f5eaa383 to your computer and use it in GitHub Desktop.
This file contains 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": { | |
"storageAccountName": { | |
"type": "string", | |
"metadata": { | |
"description": "Name of storage account" | |
} | |
}, | |
"adminUsername": { | |
"type": "string", | |
"metadata": { | |
"description": "Admin username" | |
} | |
}, | |
"sshKeyData": { | |
"type": "string", | |
"metadata": { | |
"description": "SSH rsa public key file as a string." | |
} | |
}, | |
"dnsNameforLBIP": { | |
"type": "string", | |
"metadata": { | |
"description": "DNS for Load Balancer IP" | |
} | |
}, | |
"vmNamePrefix": { | |
"type": "string", | |
"defaultValue": "myVM", | |
"metadata": { | |
"description": "Prefix to use for VM names" | |
} | |
}, | |
"imagePublisher": { | |
"type": "string", | |
"defaultValue": "Canonical", | |
"metadata": { | |
"description": "Image Publisher" | |
} | |
}, | |
"imageOffer": { | |
"type": "string", | |
"defaultValue": "UbuntuServer", | |
"metadata": { | |
"description": "Image Offer" | |
} | |
}, | |
"imageSKU": { | |
"type": "string", | |
"defaultValue": "14.04.2-LTS", | |
"metadata": { | |
"description": "Image SKU" | |
} | |
}, | |
"lbName": { | |
"type": "string", | |
"defaultValue": "myLB", | |
"metadata": { | |
"description": "Load Balancer name" | |
} | |
}, | |
"nicNamePrefix": { | |
"type": "string", | |
"defaultValue": "nic", | |
"metadata": { | |
"description": "Network Interface name prefix" | |
} | |
}, | |
"publicIPAddressName": { | |
"type": "string", | |
"defaultValue": "myPublicIP", | |
"metadata": { | |
"description": "Public IP Name" | |
} | |
}, | |
"vnetName": { | |
"type": "string", | |
"defaultValue": "myVNET", | |
"metadata": { | |
"description": "VNET name" | |
} | |
}, | |
"vmSize": { | |
"type": "string", | |
"defaultValue": "Standard_D1", | |
"metadata": { | |
"description": "Size of the VM" | |
} | |
}, | |
"customScriptConfigStorageAccountName": { | |
"type": "string", | |
"metadata": { | |
"description": "Private storage account name in which you are storing your certificates for ansible and the template bash scripts" | |
} | |
}, | |
"customScriptConfigStorageAccountKey": { | |
"type": "string", | |
"metadata": { | |
"description": "Private storage account key" | |
} | |
}, | |
}, | |
"variables": { | |
"storageAccountType": "Standard_LRS", | |
"availabilitySetName": "myAvSet", | |
"addressPrefix": "10.0.0.0/16", | |
"customScriptFilePath": "https://goasp.blob.core.windows.net/deploy.sh", | |
"subnetName": "Subnet-1", | |
"subnetPrefix": "10.0.0.0/24", | |
"publicIPAddressType": "Dynamic", | |
"vnetID": "[resourceId('Microsoft.Network/virtualNetworks',parameters('vnetName'))]", | |
"subnetRef": "[concat(variables('vnetID'),'/subnets/',variables ('subnetName'))]", | |
"publicIPAddressID": "[resourceId('Microsoft.Network/publicIPAddresses',parameters('publicIPAddressName'))]", | |
"numberOfInstances": 2, | |
"sshKeyPath": "[concat('/home/',parameters('adminUsername'),'/.ssh/authorized_keys')]", | |
"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')]" | |
}, | |
"resources": [ | |
{ | |
"type": "Microsoft.Storage/storageAccounts", | |
"name": "[parameters('storageAccountName')]", | |
"apiVersion": "2015-05-01-preview", | |
"location": "[resourceGroup().location]", | |
"properties": { | |
"accountType": "[variables('storageAccountType')]" | |
} | |
}, | |
{ | |
"type": "Microsoft.Compute/availabilitySets", | |
"name": "[variables('availabilitySetName')]", | |
"apiVersion": "2015-05-01-preview", | |
"location": "[resourceGroup().location]", | |
"properties": {} | |
}, | |
{ | |
"apiVersion": "2015-05-01-preview", | |
"type": "Microsoft.Network/publicIPAddresses", | |
"name": "[parameters('publicIPAddressName')]", | |
"location": "[resourceGroup().location]", | |
"properties": { | |
"publicIPAllocationMethod": "[variables('publicIPAddressType')]", | |
"dnsSettings": { | |
"domainNameLabel": "[parameters('dnsNameforLBIP')]" | |
} | |
} | |
}, | |
{ | |
"apiVersion": "2015-05-01-preview", | |
"type": "Microsoft.Network/virtualNetworks", | |
"name": "[parameters('vnetName')]", | |
"location": "[resourceGroup().location]", | |
"properties": { | |
"addressSpace": { | |
"addressPrefixes": [ | |
"[variables('addressPrefix')]" | |
] | |
}, | |
"subnets": [ | |
{ | |
"name": "[variables('subnetName')]", | |
"properties": { | |
"addressPrefix": "[variables('subnetPrefix')]" | |
} | |
} | |
] | |
} | |
}, | |
{ | |
"apiVersion": "2015-05-01-preview", | |
"type": "Microsoft.Network/networkInterfaces", | |
"name": "[concat(parameters('nicNamePrefix'), copyindex())]", | |
"location": "[resourceGroup().location]", | |
"copy": { | |
"name": "nicLoop", | |
"count": "[variables('numberOfInstances')]" | |
}, | |
"dependsOn": [ | |
"[concat('Microsoft.Network/virtualNetworks/', parameters('vnetName'))]", | |
"[concat('Microsoft.Network/loadBalancers/', parameters('lbName'))]" | |
], | |
"properties": { | |
"ipConfigurations": [ | |
{ | |
"name": "ipconfig1", | |
"properties": { | |
"privateIPAllocationMethod": "Dynamic", | |
"subnet": { | |
"id": "[variables('subnetRef')]" | |
}, | |
"loadBalancerBackendAddressPools": [ | |
{ | |
"id": "[concat(variables('lbID'), '/backendAddressPools/BackendPool1')]" | |
} | |
], | |
"loadBalancerInboundNatRules": [ | |
{ | |
"id": "[concat(variables('lbID'),'/inboundNatRules/SSH-VM', copyindex())]" | |
} | |
] | |
} | |
} | |
] | |
} | |
}, | |
{ | |
"apiVersion": "2015-05-01-preview", | |
"name": "[parameters('lbName')]", | |
"type": "Microsoft.Network/loadBalancers", | |
"location": "[resourceGroup().location]", | |
"dependsOn": [ | |
"[concat('Microsoft.Network/publicIPAddresses/', parameters('publicIPAddressName'))]" | |
], | |
"properties": { | |
"frontendIPConfigurations": [ | |
{ | |
"name": "LoadBalancerFrontEnd", | |
"properties": { | |
"publicIPAddress": { | |
"id": "[variables('publicIPAddressID')]" | |
} | |
} | |
} | |
], | |
"backendAddressPools": [ | |
{ | |
"name": "BackendPool1" | |
} | |
], | |
"inboundNatRules": [ | |
{ | |
"name": "SSH-VM0", | |
"properties": { | |
"frontendIPConfiguration": { | |
"id": "[variables('frontEndIPConfigID')]" | |
}, | |
"protocol": "tcp", | |
"frontendPort": 50001, | |
"backendPort": 22, | |
"enableFloatingIP": false | |
} | |
}, | |
{ | |
"name": "SSH-VM1", | |
"properties": { | |
"frontendIPConfiguration": { | |
"id": "[variables('frontEndIPConfigID')]" | |
}, | |
"protocol": "tcp", | |
"frontendPort": 50002, | |
"backendPort": 22, | |
"enableFloatingIP": false | |
} | |
} | |
], | |
"loadBalancingRules": [ | |
{ | |
"name": "HTTP", | |
"properties": { | |
"frontendIPConfiguration": { | |
"id": "[variables('frontEndIPConfigID')]" | |
}, | |
"backendAddressPool": { | |
"id": "[variables('lbPoolID')]" | |
}, | |
"protocol": "tcp", | |
"frontendPort": 80, | |
"backendPort": 80, | |
"enableFloatingIP": false, | |
"idleTimeoutInMinutes": 5, | |
"probe": { | |
"id": "[variables('lbProbeID')]" | |
} | |
} | |
}, | |
{ | |
"name": "HTTPS", | |
"properties": { | |
"frontendIPConfiguration": { | |
"id": "[variables('frontEndIPConfigID')]" | |
}, | |
"backendAddressPool": { | |
"id": "[variables('lbPoolID')]" | |
}, | |
"protocol": "tcp", | |
"frontendPort": 443, | |
"backendPort": 443, | |
"enableFloatingIP": false, | |
"idleTimeoutInMinutes": 5, | |
"probe": { | |
"id": "[variables('lbProbeID')]" | |
} | |
} | |
} | |
], | |
"probes": [ | |
{ | |
"name": "tcpProbe", | |
"properties": { | |
"protocol": "tcp", | |
"port": 80, | |
"intervalInSeconds": "5", | |
"numberOfProbes": "2" | |
} | |
} | |
] | |
} | |
}, | |
{ | |
"apiVersion": "2015-06-15", | |
"type": "Microsoft.Compute/virtualMachines", | |
"name": "[concat(parameters('vmNamePrefix'), copyindex())]", | |
"copy": { | |
"name": "virtualMachineLoop", | |
"count": "[variables('numberOfInstances')]" | |
}, | |
"location": "[resourceGroup().location]", | |
"dependsOn": [ | |
"[concat('Microsoft.Storage/storageAccounts/', parameters('storageAccountName'))]", | |
"[concat('Microsoft.Network/networkInterfaces/', parameters('nicNamePrefix'), copyindex())]", | |
"[concat('Microsoft.Compute/availabilitySets/', variables('availabilitySetName'))]" | |
], | |
"properties": { | |
"availabilitySet": { | |
"id": "[resourceId('Microsoft.Compute/availabilitySets',variables('availabilitySetName'))]" | |
}, | |
"hardwareProfile": { | |
"vmSize": "[parameters('vmSize')]" | |
}, | |
"osProfile": { | |
"computername": "[concat(parameters('vmNamePrefix'), copyIndex())]", | |
"adminUsername": "[parameters('adminUsername')]", | |
"linuxConfiguration": { | |
"disablePasswordAuthentication": "true", | |
"ssh": { | |
"publicKeys": [ | |
{ | |
"path": "[variables('sshKeyPath')]", | |
"keyData": "[parameters('sshKeyData')]" | |
} | |
] | |
} | |
} | |
}, | |
"storageProfile": { | |
"imageReference": { | |
"publisher": "[parameters('imagePublisher')]", | |
"offer": "[parameters('imageOffer')]", | |
"sku": "[parameters('imageSKU')]", | |
"version": "latest" | |
}, | |
"osDisk": { | |
"name": "osdisk", | |
"vhd": { | |
"uri": "[concat('http://',parameters('storageAccountName'),'.blob.core.windows.net/vhds/','osdisk', copyindex(), '.vhd')]" | |
}, | |
"caching": "ReadWrite", | |
"createOption": "FromImage" | |
} | |
}, | |
"networkProfile": { | |
"networkInterfaces": [ | |
{ | |
"id": "[resourceId('Microsoft.Network/networkInterfaces',concat(parameters('nicNamePrefix'),copyindex()))]" | |
} | |
] | |
}, | |
"diagnosticsProfile": { | |
"bootDiagnostics": { | |
"enabled": "true", | |
"storageUri": "[concat('http://',parameters('storageAccountName'),'.blob.core.windows.net')]" | |
} | |
} | |
} | |
}, | |
{ | |
"name": "[concat(parameters('vmNamePrefix'), '0', '/extension')]", | |
"type": "Microsoft.Compute/virtualMachines/extensions", | |
"location": "[resourceGroup().location]", | |
"apiVersion": "2015-06-15", | |
"dependsOn": [ | |
"[concat('Microsoft.Compute/virtualMachines/', concat(parameters('vmNamePrefix'), '0'))]" | |
], | |
"properties": { | |
"publisher": "Microsoft.OSTCExtensions", | |
"type": "CustomScriptForLinux", | |
"typeHandlerVersion": "1.3", | |
"autoUpgradeMinorVersion": true, | |
"settings": { | |
"fileUris": [ | |
"[variables('customScriptFilePath')]", | |
"https://goasp.blob.core.windows.net/ssl/server.crt", | |
"https://goasp.blob.core.windows.net/ssl/server.key" | |
], | |
"commandToExecute": "bash deploy.sh" | |
}, | |
"protectedSettings": { | |
"storageAccountName": "[parameters('customScriptConfigStorageAccountName')]", | |
"storageAccountKey": "[parameters('customScriptConfigStorageAccountKey')]" | |
} | |
} | |
}, | |
{ | |
"name": "[concat(parameters('vmNamePrefix'), '1', '/extension')]", | |
"type": "Microsoft.Compute/virtualMachines/extensions", | |
"location": "[resourceGroup().location]", | |
"apiVersion": "2015-06-15", | |
"dependsOn": [ | |
"[concat('Microsoft.Compute/virtualMachines/', concat(parameters('vmNamePrefix'), '1'))]" | |
], | |
"properties": { | |
"publisher": "Microsoft.OSTCExtensions", | |
"type": "CustomScriptForLinux", | |
"typeHandlerVersion": "1.3", | |
"autoUpgradeMinorVersion": true, | |
"settings": { | |
"fileUris": [ | |
"[variables('customScriptFilePath')]", | |
"https://goasp.blob.core.windows.net/ssl/server.crt", | |
"https://goasp.blob.core.windows.net/ssl/server.key" | |
], | |
"commandToExecute": "bash deploy.sh" | |
}, | |
"protectedSettings": { | |
"storageAccountName": "[parameters('customScriptConfigStorageAccountName')]", | |
"storageAccountKey": "[parameters('customScriptConfigStorageAccountKey')]" | |
} | |
} | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment