Exercise - Create a Linux virtual machine with the Azure portal
Recall that our goal is to move an existing Linux server running Apache to Azure. We'll start by creating an Ubuntu Linux server.
Create a new Linux virtual machine
We can create Linux VMs with the Azure portal, the Azure CLI, or Azure PowerShell. The easiest approach when you are starting with Azure is to use the portal because it walks you through the required information and provides hints and helpful messages during the creation:
Sign into the Azure portal using the same account you activated the sandbox with.
On the Azure portal menu or from the Home page, select Create a resource.
In the search box, enter Ubuntu Server.
Under the Marketplace result, select the All results link on the top right-hand side to see the different versions available.
Select Ubuntu Server 18.04 LTS Canonical from the presented list.
Click the Create button to start configuring the VM.
Configure the VM settings
The VM creation experience in the portal is presented in a wizard format to walk you through all the configuration areas for the VM. Clicking the Next button will take you to the next configurable section. However, you can move between the sections at will with the tabs running across the top that identify each part.
Once you fill in all the required options (identified with red asterisks), you can skip the remainder of the wizard experience and start creating the VM through the Review + Create button at the bottom.
We'll start with the Basics section. These instructions are for the Sandbox portal. If you are using another Azure portal account, you may need to adapt some details accordingly.
Configure basic VM settings
For Subscription, the sandbox subscription should be selected for you by default.
For Resource group, the resource group with the name
[sandbox resource group name]should be selected for you by default.
In the Instance details section, enter a name for your web server VM, such as test-web-eus-vm1. This indicates the environment (test), the role (web), location (East US), service (vm), and instance number (1).
- It's considered best practice to standardize your resource names, so you can quickly identify their purpose. Linux VM names must be between 1 and 64 characters and be comprised of numbers, letters, and dashes.
As you change settings and tab out of each free-text field, Azure will validate each value automatically and place a green check mark next to it when it's good. You can hover your mouse pointer over error indicators to get more information on issues it discovers.
Select a location.
The free sandbox allows you to create resources in a subset of the Azure global regions. Select a region from the following list when you create resources:
- West US 2
- South Central US
- Central US
- East US
- West Europe
- Southeast Asia
- Japan East
- Brazil South
- Australia Southeast
- Central India
Set Availability options to No infrastructure redundancy required. This option can be used to ensure the VM is highly available by grouping multiple VMs together as a set to deal with planned or unplanned maintenance events or outages. For this exercise we will not need this service.
Ensure that the image is set to Ubuntu Server 18.04 LTS. You can open the drop-down list to see all the options available.
Leave the Size field with the default of D2s v3 choice, which gives you two vCPUs with 8 GB of RAM.
Moving on to the Administrator account section, for Authentication type select the SSH public key option.
Enter a username you'll use to sign in with SSH. Choose something you can remember or write it down.
Copy the SSH key from your public key file you created in the previous unit and paste it into the SSH public key field.
When you copy the public key into the Azure portal, make sure not to add any additional whitespace or line-feed characters.
In the INBOUND PORT RULES section, first select Allow selected ports. Since this is a Linux VM, we want to be able to access the VM using SSH remotely. Scroll the Select inbound ports list if necessary until you find SSH (22) and enable it.
Configure disks for the VM
Click Next: Disks > to move to the Disks section.
Choose Premium SSD for the OS disk type.
Create a data disk
Recall that we will get an OS disk (/dev/sda) and a temporary disk (/dev/sdb). Let's add a data disk as well:
Click the Create and attach a new disk link in the Data disks section.
You can take all the defaults: Premium SSD, the auto-generated name, size of 1023 GiB, and None (empty disk) for Source type, although notice that source type is where you could use a snapshot or Azure Blob storage to create a VHD.
Click OK to create the disk and go back to the Data disks section.
There should now be a new disk in the first row.
Configure the network
Click Next: Networking > to move to the Networking section.
In a production environment where we already have other components, you'd want to utilize an existing virtual network. That way, your VM can communicate with the other cloud services in your solution. If there isn't one defined in this location yet, you can create it here and configure the:
- Address space: The overall IPV4 space available to this network.
- Subnets: The first subnet to subdivide the address space - it must fit within the defined address space. Once the VNet is created, you can add additional subnets.
By default, Azure will create a virtual network, network interface, and public IP for your VM. It's not trivial to change the networking options after the VM has been created, so always double-check the network assignments on services you create in Azure. For this exercise, the defaults should work fine.
Finish configuring the VM and create the image
The rest of the options have reasonable defaults, and there's no need to change any of them. You can explore the other tabs if you like. The individual options have an
(i) icon next to them that will show a help tip to explain the option. This is a great way to learn about the various options you can use to configure the VM:
Click the Review + create button at the bottom of the panel.
The system will validate your options and give you details about the VM being created.
Click Create to create and deploy the VM. The Azure dashboard will show the VM that's being deployed. This may take several minutes.
While that's deploying, let's look at what we can do with this VM.