{ "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", "contentVersion": "1.0.0.0", "parameters": { "vmSize": { "type": "string", "defaultValue": "Standard_D2s_v3", "metadata": { "description": "VM size" } }, "vm0Name": { "type": "string", "defaultValue": "az104-06-vm0", "metadata": { "description": "VM0 name" } }, "vm1Name": { "type": "string", "defaultValue": "az104-06-vm1", "metadata": { "description": "VM1 name" } }, "adminUsername": { "type": "string", "metadata": { "description": "Admin username" } }, "adminPassword": { "type": "securestring", "metadata": { "description": "Admin password" } }, "virtualNetworkName": { "type": "string", "defaultValue": "az104-06-vnet01", "metadata": { "description": "Virtual network name" } } }, "variables": { "vm0Name": "[parameters('vm0Name')]", "vm1Name": "[parameters('vm1Name')]", "vmExtensionName": "customScriptExtension", "nic0": "az104-06-nic0", "nic1": "az104-06-nic1", "virtualNetworkName": "[parameters('virtualNetworkName')]", "nsgName": "az104-06-nsg01", "subnet0Name": "subnet0", "subnet1Name": "subnet1", "subnet1Ref": "[resourceId('Microsoft.Network/virtualNetworks/subnets', variables('virtualNetworkName'), variables('subnet0Name'))]", "subnet2Ref": "[resourceId('Microsoft.Network/virtualNetworks/subnets', variables('virtualNetworkName'), variables('subnet1Name'))]", "computeApiVersion": "2018-06-01", "networkApiVersion": "2018-08-01" }, "resources": [ { "name": "[variables('vm0Name')]", "type": "Microsoft.Compute/virtualMachines", "apiVersion": "[variables('computeApiVersion')]", "location": "[resourceGroup().location]", "comments": "The first VM", "dependsOn": [ "[variables('nic0')]" ], "properties": { "osProfile": { "computerName": "[variables('vm0Name')]", "adminUsername": "[parameters('adminUsername')]", "adminPassword": "[parameters('adminPassword')]", "windowsConfiguration": { "provisionVmAgent": "true" } }, "hardwareProfile": { "vmSize": "[parameters('vmSize')]" }, "storageProfile": { "imageReference": { "publisher": "MicrosoftWindowsServer", "offer": "WindowsServer", "sku": "2019-Datacenter", "version": "latest" }, "osDisk": { "createOption": "fromImage" }, "dataDisks": [] }, "networkProfile": { "networkInterfaces": [ { "properties": { "primary": true }, "id": "[resourceId('Microsoft.Network/networkInterfaces', variables('nic0'))]" } ] } } }, { "type": "Microsoft.Compute/virtualMachines/extensions", "name": "[concat(variables('vm0Name'), '/', variables('vmExtensionName'))]", "apiVersion": "[variables('computeApiVersion')]", "location": "[resourceGroup().location]", "dependsOn": [ "[concat('Microsoft.Compute/virtualMachines/', variables('vm0Name'))]" ], "properties": { "publisher": "Microsoft.Compute", "type": "CustomScriptExtension", "typeHandlerVersion": "1.7", "autoUpgradeMinorVersion": true, "settings": { "commandToExecute": "powershell.exe Install-WindowsFeature -name Web-Server -IncludeManagementTools && powershell.exe remove-item 'C:\\inetpub\\wwwroot\\iisstart.htm' && powershell.exe Add-Content -Path 'C:\\inetpub\\wwwroot\\iisstart.htm' -Value $('Hello World from ' + $env:computername)" } } }, { "name": "[variables('vm1Name')]", "type": "Microsoft.Compute/virtualMachines", "apiVersion": "[variables('computeApiVersion')]", "location": "[resourceGroup().location]", "comments": "The second VM", "dependsOn": [ "[variables('nic1')]" ], "properties": { "osProfile": { "computerName": "[variables('vm1Name')]", "adminUsername": "[parameters('adminUsername')]", "adminPassword": "[parameters('adminPassword')]", "windowsConfiguration": { "provisionVmAgent": "true" } }, "hardwareProfile": { "vmSize": "[parameters('vmSize')]" }, "storageProfile": { "imageReference": { "publisher": "MicrosoftWindowsServer", "offer": "WindowsServer", "sku": "2019-Datacenter", "version": "latest" }, "osDisk": { "createOption": "fromImage" }, "dataDisks": [] }, "networkProfile": { "networkInterfaces": [ { "properties": { "primary": true }, "id": "[resourceId('Microsoft.Network/networkInterfaces', variables('nic1'))]" } ] } } }, { "type": "Microsoft.Compute/virtualMachines/extensions", "name": "[concat(variables('vm1Name'), '/', variables('vmExtensionName'))]", "apiVersion": "[variables('computeApiVersion')]", "location": "[resourceGroup().location]", "dependsOn": [ "[concat('Microsoft.Compute/virtualMachines/', variables('vm1Name'))]" ], "properties": { "publisher": "Microsoft.Compute", "type": "CustomScriptExtension", "typeHandlerVersion": "1.7", "autoUpgradeMinorVersion": true, "settings": { "commandToExecute": "powershell.exe Install-WindowsFeature -name Web-Server -IncludeManagementTools && powershell.exe remove-item 'C:\\inetpub\\wwwroot\\iisstart.htm' && powershell.exe Add-Content -Path 'C:\\inetpub\\wwwroot\\iisstart.htm' -Value $('Hello World from ' + $env:computername)" } } }, { "type": "Microsoft.Network/virtualNetworks", "name": "[variables('virtualNetworkName')]", "apiVersion": "[variables('networkApiVersion')]", "location": "[resourceGroup().location]", "comments": "Virtual Network", "properties": { "addressSpace": { "addressPrefixes": [ "10.60.0.0/22" ] }, "subnets": [ { "name": "[variables('subnet0Name')]", "properties": { "addressPrefix": "10.60.0.0/24" } }, { "name": "[variables('subnet1Name')]", "properties": { "addressPrefix": "10.60.1.0/24" } } ] } }, { "name": "[variables('nic0')]", "type": "Microsoft.Network/networkInterfaces", "apiVersion": "[variables('networkApiVersion')]", "location": "[resourceGroup().location]", "comments": "Primary NIC", "dependsOn": [ "[variables('nsgName')]", "[concat('Microsoft.Network/virtualNetworks/', variables('virtualNetworkName'))]" ], "properties": { "ipConfigurations": [ { "name": "ipconfig1", "properties": { "subnet": { "id": "[variables('subnet1Ref')]" }, "privateIPAllocationMethod": "Dynamic" } } ], "networkSecurityGroup": { "id": "[resourceId('Microsoft.Network/networkSecurityGroups', variables('nsgName'))]" } } }, { "name": "[variables('nic1')]", "type": "Microsoft.Network/networkInterfaces", "apiVersion": "[variables('networkApiVersion')]", "location": "[resourceGroup().location]", "comments": "Primary NIC", "dependsOn": [ "[variables('nsgName')]", "[concat('Microsoft.Network/virtualNetworks/', variables('virtualNetworkName'))]" ], "properties": { "ipConfigurations": [ { "name": "ipconfig1", "properties": { "subnet": { "id": "[variables('subnet2Ref')]" }, "privateIPAllocationMethod": "Dynamic" } } ], "networkSecurityGroup": { "id": "[resourceId('Microsoft.Network/networkSecurityGroups', variables('nsgName'))]" } } }, { "name": "[variables('nsgName')]", "type": "Microsoft.Network/networkSecurityGroups", "apiVersion": "[variables('networkApiVersion')]", "location": "[resourceGroup().location]", "comments": "Network Security Group (NSG) for Primary NIC", "properties": { "securityRules": [ { "name": "default-allow-rdp", "properties": { "priority": 1000, "sourceAddressPrefix": "*", "protocol": "Tcp", "destinationPortRange": "3389", "access": "Allow", "direction": "Inbound", "sourcePortRange": "*", "destinationAddressPrefix": "*" } }, { "name": "default-allow-http", "properties": { "priority": 1100, "sourceAddressPrefix": "*", "protocol": "Tcp", "destinationPortRange": "80", "access": "Allow", "direction": "Inbound", "sourcePortRange": "*", "destinationAddressPrefix": "*" } } ] } } ], "outputs": {} }