{ "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", "contentVersion": "1.0.0.0", "parameters": { "adminUsername": { "type": "string", "metadata": { "description": "User name for the Virtual Machine." } }, "adminPassword": { "type": "securestring", "metadata": { "description": "Password for the Virtual Machine." } }, "vmName": { "type": "string", "metadata": { "description": "Name for the virtual machine" }, "defaultValue": "myUbuntuVm" }, "dnsLabelPrefix": { "type": "string", "metadata": { "description": "Unique DNS Name for the Public IP used to access the Virtual Machine." } }, "ubuntuOSVersion": { "type": "string", "defaultValue": "16.04-LTS", "allowedValues": [ "14.04-LTS", "16.04-LTS", "17.04", "17.10" ], "metadata": { "description": "The Ubuntu version for the VM. This will pick a fully patched image of this given Ubuntu version." } }, "vnetName": { "type": "string", "metadata": { "description": "Name for the virtual network" } }, "vnetPrefix": { "type": "string", "defaultValue": "10.0.0.0/16", "metadata": { "description": "CIDR address space for the virtual network" } }, "subnetName": { "type": "string", "defaultValue": "Subnet", "metadata": { "description": "Name for the subnet - defaults to Subnet" } }, "subnetPrefix": { "type": "string", "defaultValue": "10.0.0.0/24", "metadata": { "description": "CIDR address space for the subnet" } } }, "variables": { "vnetID": "[resourceId('Microsoft.Network/virtualNetworks/', parameters('vnetName'))]", "subnetRef": "[concat(variables('vnetID'), '/subnets/', parameters('subnetName'))]", "nicName": "[concat(parameters('vmName'), '-nic')]", "pipName": "[concat(parameters('vmName'), '-pip')]", "pipType": "Dynamic", "vmSize": "Standard_B1s", "imagePublisher": "Canonical", "imageOffer": "UbuntuServer", "storageAccountType": "Standard_LRS", "storageAccountName": "[concat(uniquestring(resourceGroup().id), 'salinuxvm')]", "vmId": "[resourceId('Microsoft.Compute/virtualMachines/', parameters('vmName'))]" }, "resources": [ { "type": "Microsoft.Storage/storageAccounts", "name": "[variables('storageAccountName')]", "apiVersion": "2017-06-01", "location": "[resourceGroup().location]", "sku": { "name": "[variables('storageAccountType')]" }, "kind": "Storage", "properties": {} }, { "apiVersion": "2017-06-01", "type": "Microsoft.Network/publicIPAddresses", "name": "[variables('pipName')]", "location": "[resourceGroup().location]", "properties": { "publicIPAllocationMethod": "[variables('pipType')]", "dnsSettings": { "domainNameLabel": "[parameters('dnsLabelPrefix')]" } } }, { "apiVersion": "2017-06-01", "type": "Microsoft.Network/virtualNetworks", "name": "[parameters('vnetName')]", "location": "[resourceGroup().location]", "properties": { "addressSpace": { "addressPrefixes": [ "[parameters('vnetPrefix')]" ] }, "subnets": [ { "name": "[parameters('subnetName')]", "properties": { "addressPrefix": "[parameters('subnetPrefix')]" } } ] } }, { "apiVersion": "2017-06-01", "type": "Microsoft.Network/networkInterfaces", "name": "[variables('nicName')]", "location": "[resourceGroup().location]", "dependsOn": [ "[resourceId('Microsoft.Network/publicIPAddresses/', variables('pipName'))]", "[variables('vnetID')]" ], "properties": { "ipConfigurations": [ { "name": "ipconfig1", "properties": { "privateIPAllocationMethod": "Dynamic", "publicIPAddress": { "id": "[resourceId('Microsoft.Network/publicIPAddresses',variables('pipName'))]" }, "subnet": { "id": "[variables('subnetRef')]" } } } ] } }, { "apiVersion": "2017-03-30", "type": "Microsoft.Compute/virtualMachines", "name": "[parameters('vmName')]", "location": "[resourceGroup().location]", "dependsOn": [ "[resourceId('Microsoft.Storage/storageAccounts/', variables('storageAccountName'))]", "[resourceId('Microsoft.Network/networkInterfaces/', variables('nicName'))]" ], "properties": { "hardwareProfile": { "vmSize": "[variables('vmSize')]" }, "osProfile": { "computerName": "[parameters('vmName')]", "adminUsername": "[parameters('adminUsername')]", "adminPassword": "[parameters('adminPassword')]" }, "storageProfile": { "imageReference": { "publisher": "[variables('imagePublisher')]", "offer": "[variables('imageOffer')]", "sku": "[parameters('ubuntuOSVersion')]", "version": "latest" }, "osDisk": { "createOption": "FromImage" }, "dataDisks": [ { "diskSizeGB": 1023, "lun": 0, "createOption": "Empty" } ] }, "networkProfile": { "networkInterfaces": [ { "id": "[resourceId('Microsoft.Network/networkInterfaces',variables('nicName'))]" } ] }, "diagnosticsProfile": { "bootDiagnostics": { "enabled": true, "storageUri": "[concat(reference(concat('Microsoft.Storage/storageAccounts/', variables('storageAccountName')), '2016-01-01').primaryEndpoints.blob)]" } } } } ], "outputs": { "hostname": { "type": "string", "value": "[reference(variables('pipName')).dnsSettings.fqdn]" }, "sshCommand": { "type": "string", "value": "[concat('ssh ', parameters('adminUsername'), '@', reference(variables('pipName')).dnsSettings.fqdn)]" }, "osDiskId": { "type": "string", "value": "[reference(variables('vmId')).storageProfile.osDisk.managedDisk.id]" } } }