Skip to content

Instantly share code, notes, and snippets.

@aadennis
Created February 12, 2017 22:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aadennis/1d62b4febc14790c462d0298d8186e08 to your computer and use it in GitHub Desktop.
Save aadennis/1d62b4febc14790c462d0298d8186e08 to your computer and use it in GitHub Desktop.
ARM deployment template that supports 1 to N VMs. Windows
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"vmName": {
"type": "string",
"metadata": {
"description": "Name of the VM without any array suffix"
}
},
"adminUsername": {
"type": "string",
"metadata": {
"description": "Admin username for VM"
}
},
"adminPassword": {
"type": "securestring",
"metadata": {
"description": "Admin password for VM"
}
},
"vmCount": {
"type": "int",
"defaultValue": 2,
"minValue": 2,
"maxValue": 5,
"metadata": {
"description": "Number of VMs to deploy, limit 5 since this sample is using a single storage account"
}
},
"OS": {
"type": "string",
"defaultValue": "Windows",
"allowedValues": [
"Windows"
],
"metadata": {
"description": "OS Platform for the VM"
}
}
},
"variables": {
"virtualNetworkName": "myVNET",
"addressPrefix": "10.0.0.0/16",
"subnet1Name": "Subnet-1",
"subnet1Prefix": "10.0.0.0/24",
"subnet1Ref": "[resourceId('Microsoft.Network/virtualNetworks/subnets',variables('virtualNetworkName'),variables('subnet1Name'))]",
"availabilitySetName": "myAvSet",
"Windows": {
"publisher": "MicrosoftWindowsServer",
"offer": "WindowsServer",
"sku": "2016-Datacenter",
"version": "latest"
},
"imageReference": "[variables(parameters('OS'))]",
"pipName": "[concat(parameters('vmName'), 'pip')]"
},
"resources": [
{
"type": "Microsoft.Network/virtualNetworks",
"name": "[variables('virtualNetworkName')]",
"apiVersion": "2016-03-30",
"location": "[resourceGroup().location]",
"properties": {
"addressSpace": {
"addressPrefixes": [
"[variables('addressPrefix')]"
]
},
"subnets": [
{
"name": "[variables('subnet1Name')]",
"properties": {
"addressPrefix": "[variables('subnet1Prefix')]"
}
}
]
}
},
{
"type": "Microsoft.Network/networkInterfaces",
"name": "[concat('nic', copyindex(1))]",
"apiVersion": "2016-03-30",
"location": "[resourceGroup().location]",
"copy": {
"name": "nicLoop",
"count": "[parameters('vmCount')]"
},
"dependsOn": [
"[variables('virtualNetworkName')]",
"pipLoop"
],
"properties": {
"ipConfigurations": [
{
"name": "ipconfig1",
"properties": {
"privateIPAllocationMethod": "Dynamic",
"publicIPAddress": {
"id": "[concat(resourceId('Microsoft.Network/publicIPAddresses',variables('pipName')),copyIndex(1))]"
},
"subnet": {
"id": "[variables('subnet1Ref')]"
}
}
}
]
}
},
{
"apiVersion": "2015-06-15",
"type": "Microsoft.Network/publicIPAddresses",
"name": "[concat(variables('pipName'), copyIndex(1))]",
"location": "[resourceGroup().location]",
"copy": {
"name": "pipLoop",
"count": "[parameters('vmCount')]"
},
"properties": {
"publicIPAllocationMethod": "Static",
"dnsSettings": {
"domainNameLabel": "[concat(parameters('vmName'), copyIndex(1))]",
"fqdn": "[concat(parameters('vmName'), copyIndex(1) ,'.uksouth.cloudapp.azure.com')]"
}
},
"tags": {
"displayName": "PublicIPAddress - Web"
}
},
{
"type": "Microsoft.Compute/virtualMachines",
"name": "[concat(parameters('vmName'), copyIndex(1))]",
"apiVersion": "2016-04-30-preview",
"location": "[resourceGroup().location]",
"copy": {
"name": "virtualMachineLoop",
"count": "[parameters('vmCount')]"
},
"dependsOn": [
"nicLoop",
"pipLoop"
],
"properties": {
"hardwareProfile": {
"vmSize": "Standard_D1_v2"
},
"osProfile": {
"computerName": "[concat('vm', copyIndex(1))]",
"adminUsername": "[parameters('adminUsername')]",
"adminPassword": "[parameters('adminPassword')]"
},
"storageProfile": {
"imageReference": "[variables('imageReference')]",
"osDisk": {
"createOption": "FromImage"
}
},
"networkProfile": {
"networkInterfaces": [
{
"id": "[resourceId('Microsoft.Network/networkInterfaces',concat('nic', copyindex(1)))]"
}
]
}
}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment