bicep update for 101-availabilityset-multiplevm-linux

This commit is contained in:
Rakesh Kumar 2021-09-21 18:58:55 -07:00
Родитель f2f788cdcd
Коммит 058949bc1a
3 изменённых файлов: 703 добавлений и 25 удалений

Просмотреть файл

@ -0,0 +1,289 @@
@description('The name of the Administrator of the new VMs')
param adminUsername string = 'vmadmin'
@description('The password for the Administrator account of the new VMs. Default value is subscription id')
@secure()
param adminPassword string = 'Subscription#${substring(resourceGroup().id, 15, 36)}'
@description('Number of VMs to deploy, limit 5 since this sample is using a single storage account')
@allowed([
2
3
4
5
])
param numberOfInstances int = 3
@description('Size of the Data Disk')
@allowed([
100
500
750
1000
])
param dataDiskSize int = 1000
@description('VM name prefix')
param vmNamePrefix string = 'vmset-'
@description('This is the size of your VM')
@allowed([
'Standard_A1'
'Standard_A2'
'Standard_A3'
'Standard_A4'
'Standard_D1'
'Standard_D2'
'Standard_D3'
'Standard_D4'
])
param vmSize string = 'Standard_A1'
@description('dns name prefix')
param dnsPrefix string = 'vmdns'
@description('Maps to the publisher in the Azure Stack Platform Image Repository manifest file.')
param osImagePublisher string = 'Canonical'
@description('Maps to the Offer in the Azure Stack Platform Image Repository manifest file.')
param osImageOffer string = 'UbuntuServer'
@description('The Linux version for the VM. This will pick a fully patched image of this given Centos')
@allowed([
'Centos-7.4'
'16.04-LTS'
])
param osImageSKU string = '16.04-LTS'
var availabilitySetName = toLower('aSet-${resourceGroup().name}')
var storageAccountType = 'Standard_LRS'
var osImageVersion = 'latest'
var addressPrefix = '10.0.0.0/16'
var virtualNetworkName = toLower('vNet-${resourceGroup().name}')
var NICPrefix = 'vnic-'
var subnetPrefix = '10.0.0.0/24'
var subnetName = 'vmstaticsubnet'
var storageName = 'sa${uniqueString(resourceGroup().id)}'
var publicLBName = toLower('external-lb-${resourceGroup().name}')
var lbFE = toLower('external-lb-fe-${resourceGroup().name}')
var publicIPAddressName = toLower('public-ip${resourceGroup().name}')
var nsgName = toLower('vmnsg${resourceGroup().name}')
var vmContainerName = 'vhds'
resource storage 'Microsoft.Storage/storageAccounts@2019-06-01' = {
name: storageName
location: resourceGroup().location
sku: {
name: storageAccountType
}
kind: 'Storage'
dependsOn: [
publicLB
]
}
resource nsg 'Microsoft.Network/networkSecurityGroups@2018-11-01' = {
name: nsgName
location: resourceGroup().location
properties: {
securityRules: [
{
name: 'rule1'
properties: {
protocol: '*'
sourcePortRange: '*'
destinationPortRange: '*'
sourceAddressPrefix: '*'
destinationAddressPrefix: '*'
access: 'Allow'
priority: 101
direction: 'Inbound'
}
}
]
}
}
resource availabilitySet 'Microsoft.Compute/availabilitySets@2020-06-01' = {
name: availabilitySetName
location: resourceGroup().location
properties: {
platformFaultDomainCount: 1
platformUpdateDomainCount: 1
}
}
resource publicIPAddress 'Microsoft.Network/publicIPAddresses@2018-11-01' = {
name: publicIPAddressName
location: resourceGroup().location
properties: {
publicIPAllocationMethod: 'Dynamic'
dnsSettings: {
domainNameLabel: dnsPrefix
}
}
dependsOn: [
virtualNetwork
]
}
resource virtualNetwork 'Microsoft.Network/virtualNetworks@2018-11-01' = {
name: virtualNetworkName
location: resourceGroup().location
properties: {
addressSpace: {
addressPrefixes: [
addressPrefix
]
}
subnets: [
{
name: subnetName
properties: {
addressPrefix: subnetPrefix
networkSecurityGroup: {
id: nsg.id
}
}
}
]
}
}
resource publicLB 'Microsoft.Network/loadBalancers@2018-11-01' = {
name: publicLBName
location: resourceGroup().location
properties: {
frontendIPConfigurations: [
{
name: lbFE
properties: {
publicIPAddress: {
id: publicIPAddress.id
}
}
}
]
backendAddressPools: [
{
name: 'LoadBalancerBackend'
}
]
}
dependsOn: [
virtualNetwork
]
}
resource inboundNatRule 'Microsoft.Network/loadBalancers/inboundNatRules@2018-11-01' = [for i in range(0, numberOfInstances): {
name: '${publicLBName}/ssh-VM${i}'
properties: {
frontendIPConfiguration: {
id: publicLB.properties.frontendIPConfigurations[0].id
}
protocol: 'Tcp'
frontendPort: (i + 2200)
backendPort: 22
enableFloatingIP: false
}
}]
resource networkInterface 'Microsoft.Network/networkInterfaces@2018-11-01' = [for i in range(0, numberOfInstances): {
name: '${NICPrefix}${vmNamePrefix}${i}'
location: resourceGroup().location
properties: {
ipConfigurations: [
{
name: 'ipconfig1'
properties: {
privateIPAllocationMethod: 'Dynamic'
subnet: {
id: virtualNetwork.properties.subnets[0].id
}
loadBalancerBackendAddressPools: [
{
id: publicLB.properties.backendAddressPools[0].id
}
]
loadBalancerInboundNatRules: [
{
id: inboundNatRule[i].id
}
]
}
}
]
}
}]
resource virtualMachine 'Microsoft.Compute/virtualMachines@2020-06-01' = [for i in range(0, numberOfInstances): {
name: '${vmNamePrefix}${i}'
location: resourceGroup().location
properties: {
availabilitySet: {
id: availabilitySet.id
}
hardwareProfile: {
vmSize: vmSize
}
osProfile: {
computerName: '${vmNamePrefix}${i}'
adminUsername: adminUsername
adminPassword: adminPassword
}
storageProfile: {
imageReference: {
publisher: osImagePublisher
offer: osImageOffer
sku: osImageSKU
version: osImageVersion
}
osDisk: {
name: 'osdisk'
vhd: {
uri: '${reference('Microsoft.Storage/storageAccounts/${storageName}', providers('Microsoft.Storage', 'storageAccounts').apiVersions[0]).primaryEndpoints.blob}${vmContainerName}/${vmNamePrefix}${i}-osdisk.vhd'
}
caching: 'ReadWrite'
createOption: 'FromImage'
}
dataDisks: [
{
vhd: {
uri: '${reference('Microsoft.Storage/storageAccounts/${storageName}', providers('Microsoft.Storage', 'storageAccounts').apiVersions[0]).primaryEndpoints.blob}${vmContainerName}/${vmNamePrefix}${i}-data-1.vhd'
}
name: '${vmNamePrefix}${i}-data-disk1'
createOption: 'Empty'
caching: 'None'
diskSizeGB: dataDiskSize
lun: 0
}
{
vhd: {
uri: '${reference('Microsoft.Storage/storageAccounts/${storageName}', providers('Microsoft.Storage', 'storageAccounts').apiVersions[0]).primaryEndpoints.blob}${vmContainerName}/${vmNamePrefix}${i}-data-2.vhd'
}
name: '${vmNamePrefix}${i}-data-disk2'
createOption: 'Empty'
caching: 'None'
diskSizeGB: dataDiskSize
lun: 1
}
]
}
networkProfile: {
networkInterfaces: [
{
id: networkInterface[i].id
}
]
}
diagnosticsProfile: {
bootDiagnostics: {
enabled: true
storageUri: concat(reference('Microsoft.Storage/storageAccounts/${storageName}', providers('Microsoft.Storage', 'storageAccounts').apiVersions[0]).primaryEndpoints.blob)
}
}
}
dependsOn: [
storage
]
}]

Просмотреть файл

@ -1,7 +1,7 @@
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"apiProfile": "2018-03-01-hybrid",
"apiProfile": "2020-09-01-hybrid",
"parameters": {
"adminUsername": {
"type": "string",
@ -30,7 +30,7 @@
"description": "Number of VMs to deploy, limit 5 since this sample is using a single storage account"
}
},
"dataDiskSIze": {
"dataDiskSize": {
"type": "int",
"defaultValue": 1000,
"allowedValues": [
@ -76,23 +76,24 @@
},
"osImagePublisher": {
"type": "string",
"defaultValue": "Centos",
"defaultValue": "Canonical",
"metadata": {
"description": "Maps to the publisher in the Azure Stack Platform Image Repository manifest file."
}
},
"osImageOffer": {
"type": "string",
"defaultValue": "Centos-7",
"defaultValue": "UbuntuServer",
"metadata": {
"description": "Maps to the Offer in the Azure Stack Platform Image Repository manifest file."
}
},
"osImageSKU": {
"type": "string",
"defaultValue": "Centos-7.4",
"defaultValue": "16.04-LTS",
"allowedValues": [
"Centos-7.4"
"Centos-7.4",
"16.04-LTS"
],
"metadata": {
"description": "The Linux version for the VM. This will pick a fully patched image of this given Centos"
@ -113,17 +114,16 @@
"NICPrefix": "vnic-",
"subnetPrefix": "10.0.0.0/24",
"subnetName": "vmstaticsubnet",
"subnetRef": "[concat(variables('vnetID'),'/subnets/',variables('subnetName'))]",
"subnetRef": "[resourceId('Microsoft.Network/virtualNetworks/subnets/', variables('virtualNetworkName'), variables('subnetName'))]",
"storageName": "[concat('sa', uniquestring(resourceGroup().id))]",
"publicLBName": "[tolower(concat('external-lb-', resourceGroup().name))]",
"publiclbID": "[resourceId('Microsoft.Network/loadBalancers',variables('publicLBName'))]",
"publicLBID": "[resourceId('Microsoft.Network/loadBalancers', variables('publicLBName'))]",
"lbFE": "[tolower(concat('external-lb-fe-',resourceGroup().name))]",
"publiclbFEConfigID": "[concat(variables('publiclbID'),'/frontendIPConfigurations/',variables('lbFE'))]",
"publicLBFEConfigID": "[resourceId('Microsoft.Network/loadBalancers/frontendIPConfigurations', variables('publicLBName'), variables('lbFE'))]",
"publicIPAddressName": "[tolower(concat('public-ip',resourceGroup().name))]",
"rdpPort": 22,
"nsgName": "[tolower(concat('vmnsg',resourceGroup().name))]",
"nsgID": "[resourceId('Microsoft.Network/networkSecurityGroups', variables('nsgName'))]",
"vmContainerName": "vhds"
@ -131,6 +131,7 @@
"resources": [
{
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "2019-06-01",
"name": "[variables('storageName')]",
"location": "[resourceGroup().location]",
"sku": {
@ -138,11 +139,12 @@
},
"kind": "Storage",
"dependsOn": [
"[variables('publiclbName')]"
"[variables('publicLBName')]"
]
},
{
"type": "Microsoft.Network/networkSecurityGroups",
"apiVersion": "2018-11-01",
"name": "[variables('nsgName')]",
"location": "[resourceGroup().location]",
"properties": {
@ -165,15 +167,17 @@
},
{
"type": "Microsoft.Compute/availabilitySets",
"apiVersion": "2020-06-01",
"name": "[variables('availabilitySetName')]",
"location": "[resourceGroup().location]",
"properties": {
"platformFaultDomainCount": "1",
"platformUpdateDomainCount": "1"
"platformFaultDomainCount": 1,
"platformUpdateDomainCount": 1
}
},
{
"type": "Microsoft.Network/publicIPAddresses",
"apiVersion": "2018-11-01",
"name": "[variables('publicIPAddressName')]",
"location": "[resourceGroup().location]",
"properties": {
@ -188,6 +192,7 @@
},
{
"type": "Microsoft.Network/virtualNetworks",
"apiVersion": "2018-11-01",
"name": "[variables('virtualNetworkName')]",
"location": "[resourceGroup().location]",
"properties": {
@ -213,8 +218,9 @@
]
},
{
"name": "[variables('publiclbName')]",
"name": "[variables('publicLBName')]",
"type": "Microsoft.Network/loadBalancers",
"apiVersion": "2018-11-01",
"location": "[resourceGroup().location]",
"dependsOn": [
"[variables('vnetID')]",
@ -240,18 +246,18 @@
},
{
"type": "Microsoft.Network/loadBalancers/inboundNatRules",
"apiVersion": "2018-11-01",
"name": "[concat(variables('publicLBName'), '/ssh-VM', copyIndex())]",
"location": "[resourceGroup().location]",
"copy": {
"name": "lbNatLoop",
"count": "[parameters('numberOfInstances')]"
},
"dependsOn": [
"[concat('Microsoft.Network/loadBalancers/', variables('publiclbName'))]"
"[resourceId('Microsoft.Network/loadBalancers', variables('publicLBName'))]"
],
"properties": {
"frontendIPConfiguration": {
"id": "[variables('publiclbFEConfigID')]"
"id": "[variables('publicLBFEConfigID')]"
},
"protocol": "tcp",
"frontendPort": "[copyIndex(2200)]",
@ -261,6 +267,7 @@
},
{
"type": "Microsoft.Network/networkInterfaces",
"apiVersion": "2018-11-01",
"name": "[concat(variables('NICPrefix'), parameters('vmNamePrefix'), copyIndex())]",
"location": "[resourceGroup().location]",
"copy": {
@ -268,8 +275,8 @@
"count": "[parameters('numberOfInstances')]"
},
"dependsOn": [
"[concat('Microsoft.Network/virtualNetworks/', variables('virtualNetworkName'))]",
"[concat('Microsoft.Network/loadBalancers/', variables('publicLBName'))]",
"[resourceId('Microsoft.Network/virtualNetworks', variables('virtualNetworkName'))]",
"[resourceId('Microsoft.Network/loadBalancers', variables('publicLBName'))]",
"[concat('Microsoft.Network/loadBalancers/', variables('publicLBName'), '/inboundNatRules/', 'ssh-VM', copyIndex())]"
],
"properties": {
@ -283,12 +290,12 @@
},
"loadBalancerBackendAddressPools": [
{
"id": "[concat(variables('publiclbID'), '/backendAddressPools/LoadBalancerBackend')]"
"id": "[concat(variables('publicLBID'), '/backendAddressPools/LoadBalancerBackend')]"
}
],
"loadBalancerInboundNatRules": [
{
"id": "[concat(variables('publiclbID'), '/inboundNatRules/ssh-VM', copyIndex())]"
"id": "[concat(variables('publicLBID'), '/inboundNatRules/ssh-VM', copyIndex())]"
}
]
}
@ -298,6 +305,7 @@
},
{
"type": "Microsoft.Compute/virtualMachines",
"apiVersion": "2020-06-01",
"name": "[concat(parameters('vmNamePrefix'), copyIndex())]",
"location": "[resourceGroup().location]",
"copy": {
@ -305,9 +313,9 @@
"count": "[parameters('numberOfInstances')]"
},
"dependsOn": [
"[concat('Microsoft.Storage/storageAccounts/',variables('storageName'))]",
"[resourceId('Microsoft.Storage/storageAccounts',variables('storageName'))]",
"[resourceId('Microsoft.Network/networkInterfaces', concat(variables('NICPrefix'), parameters('vmNamePrefix'), copyIndex()))]",
"[concat('Microsoft.Compute/availabilitySets/', variables('availabilitySetName'))]"
"[resourceId('Microsoft.Compute/availabilitySets', variables('availabilitySetName'))]"
],
"properties": {
"availabilitySet": {
@ -368,7 +376,7 @@
},
"diagnosticsProfile": {
"bootDiagnostics": {
"enabled": "true",
"enabled": true,
"storageUri": "[concat(reference(concat('Microsoft.Storage/storageAccounts/', variables('storageName')),providers('Microsoft.Storage', 'storageAccounts').apiVersions[0]).primaryEndpoints.blob)]"
}
}

Просмотреть файл

@ -0,0 +1,381 @@
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.4.613.9944",
"templateHash": "12142450251540046373"
}
},
"parameters": {
"adminUsername": {
"type": "string",
"defaultValue": "vmadmin",
"metadata": {
"description": "The name of the Administrator of the new VMs"
}
},
"adminPassword": {
"type": "secureString",
"defaultValue": "[format('Subscription#{0}', substring(resourceGroup().id, 15, 36))]",
"metadata": {
"description": "The password for the Administrator account of the new VMs. Default value is subscription id"
}
},
"numberOfInstances": {
"type": "int",
"defaultValue": 3,
"allowedValues": [
2,
3,
4,
5
],
"metadata": {
"description": "Number of VMs to deploy, limit 5 since this sample is using a single storage account"
}
},
"dataDiskSize": {
"type": "int",
"defaultValue": 1000,
"allowedValues": [
100,
500,
750,
1000
],
"metadata": {
"description": "Size of the Data Disk"
}
},
"vmNamePrefix": {
"type": "string",
"defaultValue": "vmset-",
"metadata": {
"description": "VM name prefix"
}
},
"vmSize": {
"type": "string",
"defaultValue": "Standard_A1",
"allowedValues": [
"Standard_A1",
"Standard_A2",
"Standard_A3",
"Standard_A4",
"Standard_D1",
"Standard_D2",
"Standard_D3",
"Standard_D4"
],
"metadata": {
"description": "This is the size of your VM"
}
},
"dnsPrefix": {
"type": "string",
"defaultValue": "vmdns",
"metadata": {
"description": "dns name prefix"
}
},
"osImagePublisher": {
"type": "string",
"defaultValue": "Canonical",
"metadata": {
"description": "Maps to the publisher in the Azure Stack Platform Image Repository manifest file."
}
},
"osImageOffer": {
"type": "string",
"defaultValue": "UbuntuServer",
"metadata": {
"description": "Maps to the Offer in the Azure Stack Platform Image Repository manifest file."
}
},
"osImageSKU": {
"type": "string",
"defaultValue": "16.04-LTS",
"allowedValues": [
"Centos-7.4",
"16.04-LTS"
],
"metadata": {
"description": "The Linux version for the VM. This will pick a fully patched image of this given Centos"
}
}
},
"functions": [],
"variables": {
"availabilitySetName": "[toLower(format('aSet-{0}', resourceGroup().name))]",
"storageAccountType": "Standard_LRS",
"osImageVersion": "latest",
"addressPrefix": "10.0.0.0/16",
"virtualNetworkName": "[toLower(format('vNet-{0}', resourceGroup().name))]",
"NICPrefix": "vnic-",
"subnetPrefix": "10.0.0.0/24",
"subnetName": "vmstaticsubnet",
"storageName": "[format('sa{0}', uniqueString(resourceGroup().id))]",
"publicLBName": "[toLower(format('external-lb-{0}', resourceGroup().name))]",
"lbFE": "[toLower(format('external-lb-fe-{0}', resourceGroup().name))]",
"publicIPAddressName": "[toLower(format('public-ip{0}', resourceGroup().name))]",
"nsgName": "[toLower(format('vmnsg{0}', resourceGroup().name))]",
"vmContainerName": "vhds"
},
"resources": [
{
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "2019-06-01",
"name": "[variables('storageName')]",
"location": "[resourceGroup().location]",
"sku": {
"name": "[variables('storageAccountType')]"
},
"kind": "Storage",
"dependsOn": [
"[resourceId('Microsoft.Network/loadBalancers', variables('publicLBName'))]"
]
},
{
"type": "Microsoft.Network/networkSecurityGroups",
"apiVersion": "2018-11-01",
"name": "[variables('nsgName')]",
"location": "[resourceGroup().location]",
"properties": {
"securityRules": [
{
"name": "rule1",
"properties": {
"protocol": "*",
"sourcePortRange": "*",
"destinationPortRange": "*",
"sourceAddressPrefix": "*",
"destinationAddressPrefix": "*",
"access": "Allow",
"priority": 101,
"direction": "Inbound"
}
}
]
}
},
{
"type": "Microsoft.Compute/availabilitySets",
"apiVersion": "2020-06-01",
"name": "[variables('availabilitySetName')]",
"location": "[resourceGroup().location]",
"properties": {
"platformFaultDomainCount": 1,
"platformUpdateDomainCount": 1
}
},
{
"type": "Microsoft.Network/publicIPAddresses",
"apiVersion": "2018-11-01",
"name": "[variables('publicIPAddressName')]",
"location": "[resourceGroup().location]",
"properties": {
"publicIPAllocationMethod": "Dynamic",
"dnsSettings": {
"domainNameLabel": "[parameters('dnsPrefix')]"
}
},
"dependsOn": [
"[resourceId('Microsoft.Network/virtualNetworks', variables('virtualNetworkName'))]"
]
},
{
"type": "Microsoft.Network/virtualNetworks",
"apiVersion": "2018-11-01",
"name": "[variables('virtualNetworkName')]",
"location": "[resourceGroup().location]",
"properties": {
"addressSpace": {
"addressPrefixes": [
"[variables('addressPrefix')]"
]
},
"subnets": [
{
"name": "[variables('subnetName')]",
"properties": {
"addressPrefix": "[variables('subnetPrefix')]",
"networkSecurityGroup": {
"id": "[resourceId('Microsoft.Network/networkSecurityGroups', variables('nsgName'))]"
}
}
}
]
},
"dependsOn": [
"[resourceId('Microsoft.Network/networkSecurityGroups', variables('nsgName'))]"
]
},
{
"type": "Microsoft.Network/loadBalancers",
"apiVersion": "2018-11-01",
"name": "[variables('publicLBName')]",
"location": "[resourceGroup().location]",
"properties": {
"frontendIPConfigurations": [
{
"name": "[variables('lbFE')]",
"properties": {
"publicIPAddress": {
"id": "[resourceId('Microsoft.Network/publicIPAddresses', variables('publicIPAddressName'))]"
}
}
}
],
"backendAddressPools": [
{
"name": "LoadBalancerBackend"
}
]
},
"dependsOn": [
"[resourceId('Microsoft.Network/publicIPAddresses', variables('publicIPAddressName'))]",
"[resourceId('Microsoft.Network/virtualNetworks', variables('virtualNetworkName'))]"
]
},
{
"copy": {
"name": "inboundNatRule",
"count": "[length(range(0, parameters('numberOfInstances')))]"
},
"type": "Microsoft.Network/loadBalancers/inboundNatRules",
"apiVersion": "2018-11-01",
"name": "[format('{0}/ssh-VM{1}', variables('publicLBName'), range(0, parameters('numberOfInstances'))[copyIndex()])]",
"properties": {
"frontendIPConfiguration": {
"id": "[reference(resourceId('Microsoft.Network/loadBalancers', variables('publicLBName'))).frontendIPConfigurations[0].id]"
},
"protocol": "Tcp",
"frontendPort": "[add(range(0, parameters('numberOfInstances'))[copyIndex()], 2200)]",
"backendPort": 22,
"enableFloatingIP": false
},
"dependsOn": [
"[resourceId('Microsoft.Network/loadBalancers', variables('publicLBName'))]"
]
},
{
"copy": {
"name": "networkInterface",
"count": "[length(range(0, parameters('numberOfInstances')))]"
},
"type": "Microsoft.Network/networkInterfaces",
"apiVersion": "2018-11-01",
"name": "[format('{0}{1}{2}', variables('NICPrefix'), parameters('vmNamePrefix'), range(0, parameters('numberOfInstances'))[copyIndex()])]",
"location": "[resourceGroup().location]",
"properties": {
"ipConfigurations": [
{
"name": "ipconfig1",
"properties": {
"privateIPAllocationMethod": "Dynamic",
"subnet": {
"id": "[reference(resourceId('Microsoft.Network/virtualNetworks', variables('virtualNetworkName'))).subnets[0].id]"
},
"loadBalancerBackendAddressPools": [
{
"id": "[reference(resourceId('Microsoft.Network/loadBalancers', variables('publicLBName'))).backendAddressPools[0].id]"
}
],
"loadBalancerInboundNatRules": [
{
"id": "[resourceId('Microsoft.Network/loadBalancers/inboundNatRules', split(format('{0}/ssh-VM{1}', variables('publicLBName'), range(0, parameters('numberOfInstances'))[range(0, parameters('numberOfInstances'))[copyIndex()]]), '/')[0], split(format('{0}/ssh-VM{1}', variables('publicLBName'), range(0, parameters('numberOfInstances'))[range(0, parameters('numberOfInstances'))[copyIndex()]]), '/')[1])]"
}
]
}
}
]
},
"dependsOn": [
"[resourceId('Microsoft.Network/loadBalancers/inboundNatRules', split(format('{0}/ssh-VM{1}', variables('publicLBName'), range(0, parameters('numberOfInstances'))[range(0, parameters('numberOfInstances'))[copyIndex()]]), '/')[0], split(format('{0}/ssh-VM{1}', variables('publicLBName'), range(0, parameters('numberOfInstances'))[range(0, parameters('numberOfInstances'))[copyIndex()]]), '/')[1])]",
"[resourceId('Microsoft.Network/loadBalancers', variables('publicLBName'))]",
"[resourceId('Microsoft.Network/virtualNetworks', variables('virtualNetworkName'))]"
]
},
{
"copy": {
"name": "virtualMachine",
"count": "[length(range(0, parameters('numberOfInstances')))]"
},
"type": "Microsoft.Compute/virtualMachines",
"apiVersion": "2020-06-01",
"name": "[format('{0}{1}', parameters('vmNamePrefix'), range(0, parameters('numberOfInstances'))[copyIndex()])]",
"location": "[resourceGroup().location]",
"properties": {
"availabilitySet": {
"id": "[resourceId('Microsoft.Compute/availabilitySets', variables('availabilitySetName'))]"
},
"hardwareProfile": {
"vmSize": "[parameters('vmSize')]"
},
"osProfile": {
"computerName": "[format('{0}{1}', parameters('vmNamePrefix'), range(0, parameters('numberOfInstances'))[copyIndex()])]",
"adminUsername": "[parameters('adminUsername')]",
"adminPassword": "[parameters('adminPassword')]"
},
"storageProfile": {
"imageReference": {
"publisher": "[parameters('osImagePublisher')]",
"offer": "[parameters('osImageOffer')]",
"sku": "[parameters('osImageSKU')]",
"version": "[variables('osImageVersion')]"
},
"osDisk": {
"name": "osdisk",
"vhd": {
"uri": "[format('{0}{1}/{2}{3}-osdisk.vhd', reference(format('Microsoft.Storage/storageAccounts/{0}', variables('storageName')), providers('Microsoft.Storage', 'storageAccounts').apiVersions[0]).primaryEndpoints.blob, variables('vmContainerName'), parameters('vmNamePrefix'), range(0, parameters('numberOfInstances'))[copyIndex()])]"
},
"caching": "ReadWrite",
"createOption": "FromImage"
},
"dataDisks": [
{
"vhd": {
"uri": "[format('{0}{1}/{2}{3}-data-1.vhd', reference(format('Microsoft.Storage/storageAccounts/{0}', variables('storageName')), providers('Microsoft.Storage', 'storageAccounts').apiVersions[0]).primaryEndpoints.blob, variables('vmContainerName'), parameters('vmNamePrefix'), range(0, parameters('numberOfInstances'))[copyIndex()])]"
},
"name": "[format('{0}{1}-data-disk1', parameters('vmNamePrefix'), range(0, parameters('numberOfInstances'))[copyIndex()])]",
"createOption": "Empty",
"caching": "None",
"diskSizeGB": "[parameters('dataDiskSize')]",
"lun": 0
},
{
"vhd": {
"uri": "[format('{0}{1}/{2}{3}-data-2.vhd', reference(format('Microsoft.Storage/storageAccounts/{0}', variables('storageName')), providers('Microsoft.Storage', 'storageAccounts').apiVersions[0]).primaryEndpoints.blob, variables('vmContainerName'), parameters('vmNamePrefix'), range(0, parameters('numberOfInstances'))[copyIndex()])]"
},
"name": "[format('{0}{1}-data-disk2', parameters('vmNamePrefix'), range(0, parameters('numberOfInstances'))[copyIndex()])]",
"createOption": "Empty",
"caching": "None",
"diskSizeGB": "[parameters('dataDiskSize')]",
"lun": 1
}
]
},
"networkProfile": {
"networkInterfaces": [
{
"id": "[resourceId('Microsoft.Network/networkInterfaces', format('{0}{1}{2}', variables('NICPrefix'), parameters('vmNamePrefix'), range(0, parameters('numberOfInstances'))[range(0, parameters('numberOfInstances'))[copyIndex()]]))]"
}
]
},
"diagnosticsProfile": {
"bootDiagnostics": {
"enabled": true,
"storageUri": "[concat(reference(format('Microsoft.Storage/storageAccounts/{0}', variables('storageName')), providers('Microsoft.Storage', 'storageAccounts').apiVersions[0]).primaryEndpoints.blob)]"
}
}
},
"dependsOn": [
"[resourceId('Microsoft.Compute/availabilitySets', variables('availabilitySetName'))]",
"[resourceId('Microsoft.Network/networkInterfaces', format('{0}{1}{2}', variables('NICPrefix'), parameters('vmNamePrefix'), range(0, parameters('numberOfInstances'))[range(0, parameters('numberOfInstances'))[copyIndex()]]))]",
"[resourceId('Microsoft.Storage/storageAccounts', variables('storageName'))]"
]
}
]
}