Skip to content

Instantly share code, notes, and snippets.

@AbhiOnGithub
Created July 30, 2018 09:36
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 AbhiOnGithub/444257dd08e6de9c8721d4032d5f0c4c to your computer and use it in GitHub Desktop.
Save AbhiOnGithub/444257dd08e6de9c8721d4032d5f0c4c to your computer and use it in GitHub Desktop.
ARM Template to deploy 1 vm 2 nics 2subnets and 1vnet
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"virtualMachineSize": {
"type": "string",
"defaultValue": "Standard_DS1_v2",
"metadata": {
"description": "Virtual machine size (has to be at least the size of Standard_A3 to support 2 NICs)"
}
},
"adminUsername": {
"type": "string",
"metadata": {
"description": "Default Admin username"
}
},
"adminPassword": {
"type": "securestring",
"metadata": {
"description": "Default Admin password"
}
},
"storageAccountType": {
"type": "string",
"defaultValue": "Standard_LRS",
"metadata": {
"description": "Storage Account type for the VM and VM diagnostic storage"
},
"allowedValues": [
"Standard_LRS",
"Premium_LRS"
]
},
"location": {
"type": "string",
"defaultValue": "[resourceGroup().location]",
"metadata": {
"description": "Location for all resources."
}
}
},
"variables": {
"virtualMachineName": "VM-MultiNic",
"nic1": "nic-1",
"nic2": "nic-2",
"virtualNetworkName": "virtualNetwork",
"subnet1Name": "subnet-1",
"subnet2Name": "subnet-2",
"publicIPAddressName": "publicIp",
"subnet1Ref": "[resourceId('Microsoft.Network/virtualNetworks/subnets', variables('virtualNetworkName'), variables('subnet1Name'))]",
"subnet2Ref": "[resourceId('Microsoft.Network/virtualNetworks/subnets', variables('virtualNetworkName'), variables('subnet2Name'))]",
"diagStorageAccountName": "[concat('diags',uniqueString(resourceGroup().id))]",
"networkSecurityGroupName": "NSG"
},
"resources": [
{
"name": "[variables('virtualMachineName')]",
"type": "Microsoft.Compute/virtualMachines",
"apiVersion": "2017-03-30",
"location": "[parameters('location')]",
"comments": "This is the virtual machine that you're building.",
"dependsOn": [
"[variables('nic1')]",
"[variables('nic2')]",
"[variables('diagStorageAccountName')]"
],
"properties": {
"osProfile": {
"computerName": "[variables('virtualMachineName')]",
"adminUsername": "[parameters('adminUsername')]",
"adminPassword": "[parameters('adminPassword')]",
"windowsConfiguration": {
"provisionVmAgent": "true"
}
},
"hardwareProfile": {
"vmSize": "[parameters('virtualMachineSize')]"
},
"storageProfile": {
"imageReference": {
"publisher": "MicrosoftWindowsServer",
"offer": "WindowsServer",
"sku": "2016-Datacenter",
"version": "latest"
},
"osDisk": {
"createOption": "FromImage"
},
"dataDisks": []
},
"networkProfile": {
"networkInterfaces": [
{
"properties": {
"primary": true
},
"id": "[resourceId('Microsoft.Network/networkInterfaces', variables('nic1'))]"
},
{
"properties": {
"primary": false
},
"id": "[resourceId('Microsoft.Network/networkInterfaces', variables('nic2'))]"
}
]
},
"diagnosticsProfile": {
"bootDiagnostics": {
"enabled": true,
"storageUri": "[reference(resourceId('Microsoft.Storage/storageAccounts', variables('diagStorageAccountName')), '2017-06-01').primaryEndpoints['blob']]"
}
}
}
},
{
"type": "Microsoft.Storage/storageAccounts",
"name": "[variables('diagStorageAccountName')]",
"apiVersion": "2017-06-01",
"location": "[parameters('location')]",
"sku": {
"name": "[parameters('storageAccountType')]"
},
"kind": "Storage",
"properties": {}
},
{
"type": "Microsoft.Network/virtualNetworks",
"name": "[variables('virtualNetworkName')]",
"apiVersion": "2017-06-01",
"location": "[parameters('location')]",
"comments": "This will build a Virtual Network.",
"properties": {
"addressSpace": {
"addressPrefixes": [
"10.0.0.0/16"
]
},
"subnets": [
{
"name": "[variables('subnet1Name')]",
"properties": {
"addressPrefix": "10.0.0.0/24"
}
},
{
"name": "[variables('subnet2Name')]",
"properties": {
"addressPrefix": "10.0.1.0/24"
}
}
]
}
},
{
"name": "[variables('nic1')]",
"type": "Microsoft.Network/networkInterfaces",
"apiVersion": "2017-06-01",
"location": "[parameters('location')]",
"comments": "This will be your Primary NIC",
"dependsOn": [
"[variables('publicIpAddressName')]",
"[variables('networkSecurityGroupName')]",
"[variables('virtualNetworkName')]"
],
"properties": {
"ipConfigurations": [
{
"name": "ipconfig1",
"properties": {
"subnet": {
"id": "[variables('subnet1Ref')]"
},
"privateIPAllocationMethod": "Dynamic",
"publicIpAddress": {
"id": "[resourceId('Microsoft.Network/publicIpAddresses', variables('publicIpAddressName'))]"
}
}
}
],
"networkSecurityGroup": {
"id": "[resourceId('Microsoft.Network/networkSecurityGroups', variables('networkSecurityGroupName'))]"
}
}
},
{
"name": "[variables('nic2')]",
"type": "Microsoft.Network/networkInterfaces",
"apiVersion": "2017-06-01",
"location": "[parameters('location')]",
"comments": "This will be your Secondary NIC",
"dependsOn": [
"[concat('Microsoft.Network/virtualNetworks/', variables('virtualNetworkName'))]"
],
"properties": {
"ipConfigurations": [
{
"name": "ipconfig1",
"properties": {
"subnet": {
"id": "[variables('subnet2Ref')]"
},
"privateIPAllocationMethod": "Dynamic"
}
}
]
}
},
{
"name": "[variables('publicIpAddressName')]",
"type": "Microsoft.Network/publicIPAddresses",
"apiVersion": "2017-06-01",
"location": "[parameters('location')]",
"comments": "Public IP for your Primary NIC",
"properties": {
"publicIPAllocationMethod": "Dynamic"
}
},
{
"name": "[variables('networkSecurityGroupName')]",
"type": "Microsoft.Network/networkSecurityGroups",
"apiVersion": "2016-09-01",
"location": "[parameters('location')]",
"comments": "Network Security Group (NSG) for your Primary NIC",
"properties": {
"securityRules": [
{
"name": "default-allow-rdp",
"properties": {
"priority": 1000,
"sourceAddressPrefix": "*",
"protocol": "Tcp",
"destinationPortRange": "3389",
"access": "Allow",
"direction": "Inbound",
"sourcePortRange": "*",
"destinationAddressPrefix": "*"
}
}
]
}
}
],
"outputs": {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment