Try to deploy multiple VMs in single template
This commit is contained in:
parent
ddcbb923fc
commit
35b767203a
67
main.json
67
main.json
|
@ -32,6 +32,14 @@
|
|||
"metadata": {
|
||||
"description": "The Ubuntu version for the VM. This will pick a fully patched image of this given Ubuntu version."
|
||||
}
|
||||
},
|
||||
"nCopies": {
|
||||
"type": "int",
|
||||
"defaultValue": 2,
|
||||
"minValue": 1,
|
||||
"metadata": {
|
||||
"description": "Number of VMs to deploy"
|
||||
}
|
||||
}
|
||||
},
|
||||
"variables": {
|
||||
|
@ -54,9 +62,13 @@
|
|||
"resources": [
|
||||
{
|
||||
"type": "Microsoft.Storage/storageAccounts",
|
||||
"name": "[variables('storageAccountName')]",
|
||||
"name": "[concat(variables('storageAccountName'), '-', copyIndex())]",
|
||||
"apiVersion": "2017-06-01",
|
||||
"location": "[resourceGroup().location]",
|
||||
"copy": {
|
||||
"name": "storageloop",
|
||||
"count": "[parameters('nCopies')]"
|
||||
},
|
||||
"sku": {
|
||||
"name": "[variables('storageAccountType')]"
|
||||
},
|
||||
|
@ -66,20 +78,28 @@
|
|||
{
|
||||
"apiVersion": "2017-04-01",
|
||||
"type": "Microsoft.Network/publicIPAddresses",
|
||||
"name": "[variables('publicIPAddressName')]",
|
||||
"name": "[concat(variables('publicIPAddressName'), '-', copyIndex())]",
|
||||
"location": "[resourceGroup().location]",
|
||||
"copy": {
|
||||
"name": "iploop",
|
||||
"count": "[parameters('nCopies')]"
|
||||
},
|
||||
"properties": {
|
||||
"publicIPAllocationMethod": "[variables('publicIPAddressType')]",
|
||||
"dnsSettings": {
|
||||
"domainNameLabel": "[parameters('dnsLabelPrefix')]"
|
||||
"domainNameLabel": "[concat(parameters('dnsLabelPrefix'), '-', copyIndex())]"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"apiVersion": "2017-04-01",
|
||||
"type": "Microsoft.Network/virtualNetworks",
|
||||
"name": "[variables('virtualNetworkName')]",
|
||||
"name": "[concat(variables('virtualNetworkName'), '-', copyIndex())]",
|
||||
"location": "[resourceGroup().location]",
|
||||
"copy": {
|
||||
"name": "vnloop",
|
||||
"count": "[parameters('nCopies')]"
|
||||
},
|
||||
"properties": {
|
||||
"addressSpace": {
|
||||
"addressPrefixes": [
|
||||
|
@ -88,7 +108,7 @@
|
|||
},
|
||||
"subnets": [
|
||||
{
|
||||
"name": "[variables('subnetName')]",
|
||||
"name": "[concat(variables('subnetName'), '-', copyIndex())]",
|
||||
"properties": {
|
||||
"addressPrefix": "[variables('subnetPrefix')]"
|
||||
}
|
||||
|
@ -99,20 +119,24 @@
|
|||
{
|
||||
"apiVersion": "2017-04-01",
|
||||
"type": "Microsoft.Network/networkInterfaces",
|
||||
"name": "[variables('nicName')]",
|
||||
"name": "[concat(variables('nicName'), '-', copyIndex())]",
|
||||
"location": "[resourceGroup().location]",
|
||||
"copy": {
|
||||
"name": "vnloop",
|
||||
"count": "[parameters('nCopies')]"
|
||||
},
|
||||
"dependsOn": [
|
||||
"[resourceId('Microsoft.Network/publicIPAddresses/', variables('publicIPAddressName'))]",
|
||||
"[resourceId('Microsoft.Network/virtualNetworks/', variables('virtualNetworkName'))]"
|
||||
"[resourceId('Microsoft.Network/publicIPAddresses/', concat(variables('publicIPAddressName'), '-', copyIndex()))]",
|
||||
"[resourceId('Microsoft.Network/virtualNetworks/', concat(variables('virtualNetworkName'), '-', copyIndex()))]"
|
||||
],
|
||||
"properties": {
|
||||
"ipConfigurations": [
|
||||
{
|
||||
"name": "ipconfig1",
|
||||
"name": "[concat(ipconfig1), '-', copyIndex()]",
|
||||
"properties": {
|
||||
"privateIPAllocationMethod": "Dynamic",
|
||||
"publicIPAddress": {
|
||||
"id": "[resourceId('Microsoft.Network/publicIPAddresses',variables('publicIPAddressName'))]"
|
||||
"id": "[resourceId('Microsoft.Network/publicIPAddresses',concat(variables('publicIPAddressName'), '-', copyIndex()))]"
|
||||
},
|
||||
"subnet": {
|
||||
"id": "[variables('subnetRef')]"
|
||||
|
@ -127,16 +151,20 @@
|
|||
"type": "Microsoft.Compute/virtualMachines",
|
||||
"name": "[variables('vmName')]",
|
||||
"location": "[resourceGroup().location]",
|
||||
"copy": {
|
||||
"name": "vmloop",
|
||||
"count": "[parameters('nCopies')]"
|
||||
},
|
||||
"dependsOn": [
|
||||
"[resourceId('Microsoft.Storage/storageAccounts/', variables('storageAccountName'))]",
|
||||
"[resourceId('Microsoft.Network/networkInterfaces/', variables('nicName'))]"
|
||||
"[resourceId('Microsoft.Storage/storageAccounts/', concat(variables('storageAccountName'), '-', copyIndex()))]",
|
||||
"[resourceId('Microsoft.Network/networkInterfaces/', concat(variables('nicName'), '-', copyIndex()))]"
|
||||
],
|
||||
"properties": {
|
||||
"hardwareProfile": {
|
||||
"vmSize": "[variables('vmSize')]"
|
||||
},
|
||||
"osProfile": {
|
||||
"computerName": "[variables('vmName')]",
|
||||
"computerName": "[concat(variables('vmName'), '-', copyIndex())]",
|
||||
"adminUsername": "[parameters('adminUsername')]",
|
||||
"adminPassword": "[parameters('adminPassword')]"
|
||||
},
|
||||
|
@ -161,27 +189,20 @@
|
|||
"networkProfile": {
|
||||
"networkInterfaces": [
|
||||
{
|
||||
"id": "[resourceId('Microsoft.Network/networkInterfaces',variables('nicName'))]"
|
||||
"id": "[resourceId('Microsoft.Network/networkInterfaces', concat(variables('nicName'), '-', copyIndex()))]"
|
||||
}
|
||||
]
|
||||
},
|
||||
"diagnosticsProfile": {
|
||||
"bootDiagnostics": {
|
||||
"enabled": "true",
|
||||
"storageUri": "[concat(reference(concat('Microsoft.Storage/storageAccounts/', variables('storageAccountName')), '2016-01-01').primaryEndpoints.blob)]"
|
||||
"storageUri": "[concat(reference(concat('Microsoft.Storage/storageAccounts/', concat(variables('storageAccountName'), '-', copyIndex())), '2016-01-01').primaryEndpoints.blob)]"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"outputs": {
|
||||
"hostname": {
|
||||
"type": "string",
|
||||
"value": "[reference(variables('publicIPAddressName')).dnsSettings.fqdn]"
|
||||
},
|
||||
"sshCommand": {
|
||||
"type": "string",
|
||||
"value": "[concat('ssh ', parameters('adminUsername'), '@', reference(variables('publicIPAddressName')).dnsSettings.fqdn)]"
|
||||
}
|
||||
"adminUsername": "[parameters('adminUsername')]"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue