This article will walk through how you can create a Linux VM in Microsoft Azure.
Log in to the Azure Portal using your account, create one for free if you do not currently have one – see this short article on how to do that.
Click Create a resource in the top-left.
Select Ubuntu Server 18.04 LTS (most current at the time of writing) from the list of popular resources, if it is not shown then use the search bar to find it.
The Basics tab for Create a virtual machine will be shown. From here, the subscription should default to that assigned to your account, if needed then create a new resource group.
Give the virtual machine a name, e.g. UbuntuWebVM. Select a region close to you, note that some regions such as UK West do not allow the creation of VMs so choose one that is geographically close that does allow creation.
Click Change size and select an appropriate configuration.
When I compared the specs and prices for the cheapest VM sizes I noticed that B1S looked to have the lowest cost as the cost for B1LS was displayed as unavailable. After a quick Google search, I found these two links; the first state the suitability of B1LS as a web server and the second lists the costs – note that the costs are in GBP.
Info on the B1LS VM size
Azure VM cost (make sure to select the correct OS, Region and Pricing period)
Given that the price of the B1LS is half that of the B1S in addition to the former having a suggested target workload suited for a web server, I opted for this size.
However, it turns out that the B1LS does not have enough memory to run mysql as well as the OS, Apache and other core services. I, therefore, had to come back and change the VM size from B1LS to B1S.
The cost is deducted from the free credit on your account, assuming your account is still eligible, which it should be if you’ve just created it.
Enter a username for the VM administrator.
For authentication, the default option is SSH public key. SSH is more secure than password and it is a common way of connecting to Linux servers, like Windows RDP but at a command-line level.
To use SSH, it is necessary to create an SSH key pair. The key pair consists of a public key which is kept on the server and a private key which is kept on your computer – if the keys match then the connection can be established.
See Create SSH key pair in Azure Cloud Shell for guidance on how to create your key pair.
View the contents of the public key:
Copy the contents, including the ssh-rsa, making sure that you do not miss any characters and do not include any trailing white space. Paste this into the SSH public key section.
If the key has been pasted successfully, you should see a green tick to the right-hand side.
Click Next to configure Disks, the default is Premium SSD. Either leave it as the default or you could change this to Standard SSD, it may save a few pence on the cost.
Click Next for Networking. To make sure that the server can be contactable and serve web pages, it is necessary to carry out some network configuration.
A vnet (virtual network) is created by default so that can be left as-is. For the website(s) on the server to be available on the internet (anywhere outside of the vnet), a public IP address is needed. This should also be created by default.
The NIC (network interface card) network security group (NSG) is like a firewall but locks down traffic only allowing through what you define.
Open SSH as an inbound port so that we can connect to the VM.
Click Next for Management, go with the defaults. Note the auto-shutdown time, change this if desired.
Click Next for Advanced and Next again for Tags.
Finally, click Next to review the settings. Once the validation passes, click create to get the VM up and running.
Confirmation will be displayed once the VM has been deployed. Here you can see the various resources used with/by the VM.
The VM is now available for use and we can now connect to it and configure it as a web server.