Virtual Machines on Microsoft Azure- A Detailed Guide for Beginners

Nihal Dias
15 min readSep 5, 2021

Introduction to Cloud Computing

Read this article for an introduction to basic Cloud Computing aspects.

What is a Virtual Machine?

A Virtual Machine or a VM is like having an emulation of a computer system. For example: Running an Ubuntu VM on your Windows OS.

You can typically run a VM on either a VM software like VMware or a Cloud Computing service like Azure. Which one should you choose? Well, it depends on what you need. If you want to use a VM to run OS specific software (like ROS in Ubuntu), then I would suggest that you go for a VM software like VMware because you would need to run this software only while you use your laptop or desktop, but in cases where you need to run something (for example a server for your website) for 24 hours a day throughout the year, then using Cloud Computing services like Azure would be a better choice

With VMs, you have total control over the software and configuration of your system and unless you opt for using something like an external offline storage that you have, you don’t have to worry about the hardware as well since the cloud provider will take care of it.

VMs on Azure

Azure VMs are on-demand and scalable which means that in case more people try to access services that you run on your VM (like say a website), Azure will automatically make copies of those services and servers through which they are accessible through so that your customers can have a smooth experience while using your service.

Azure also provides additional services like monitoring your VM through system diagnostics, some great security options, and can also manage updates and patches to your OS.

Prerequisites for using Azure:

You need to have an Azure account to go ahead. Here are the types of subscriptions you could typically get:

So, what is the difference? Well, if you’re a student then I’d recommend that you use Azure’s Student Subscription which is absolutely free for students and with which you can easily access the platform with details about your college. This process is much more simplified if you use an official email id that your college/school provides you. For example, a .edu email account provided to each student in a college.

Well, what if you aren’t a student? Then you’ll have to take the Azure Subscription, which is also absolutely free for some time but you’ll have to provide your credit card details. Note that they don’t charge you after your initial free period unless you opt for the paid subscription.

Creating and configuring a VM on Microsoft Azure

Just a side note: I’ve put red rectangles on the areas that you might need to click on. Whole screenshots have been added with the purpose that the reader might be able to navigate to the required area easily.

  • Head to the Azure portal and click on ‘Create a Resource’ on the homepage.
Click on ‘Create a Resource’
  • You are now in the Azure Marketplace where you can access and create various resources for your projects. In the Search bar, type ‘Ubuntu Server’ and tap the Enter button on your keyboard. You should see an option called ‘Ubuntu Server 18.04 LTS’ (You can also use any other Ubuntu Server but I prefer using this one because it is one of the most stable among the latest versions of Ubuntu at the time of writing). Select that option.
Select the ‘Ubuntu Server 18.04 LTS’ version
  • Read all the info and then, select ‘Create’.
  • You will then be redirected to the configuration page of the VM.
  • Choose your preferred subscription and then name your VM in Virtual Machine name under ‘Instance details’. This automatically creates a new resource group for you with the name Your-VM-Name_group where Your-VM-Name refers to the name that you gave your VM.
  • Next you need to choose the region for your VM. You need to choose your VM carefully because all regions don’t have the same features. You might also experience some network latency (slow connectivity) to your VM if you don’t choose a region that is closer to your customer base. For now, I will go with Central US.
  • Your next field is ‘Availability Options’. Sometimes, a cloud data center can undergo failure or can be closed for maintenance. In those time, you cannot access your resources created in a particular server in a particular region. Thus, you have the option of replicating your data, services, etc. to a different region so that Azure can always provide a smooth experience. For now, I will leave it blank because I’m not really worried about such problems because I’m not explicitly running anything on my VM.
  • Your next option is your OS Image which is already selected for you because we opted for the Ubuntu Server 18.04 LTS. You can also click on ‘Browse all public and private images’ to check for more options.
  • Your next field is Azure Spot instance. Azure Spot instance is a cost-saving option to run a virtual machine in Azure. The VM runs when there is unused capacity on Azure infrastructure for a particular region. But if this capacity is no longer available the VM is de-allocated. I will be opting to turn it off.
  • Next you have the Size field where we’ll be selecting the number of VCPUs (Virtual CPUs) and RAM for our VM. Azure generally recommends the Standard_D2s_v3 size. You can click on the field and select ‘See all sizes’ to view other options which may be cheaper or which may better suit you’re needs. If you’re just trying out Azure, I would suggest going with the B1ls.
  • Our next field is for Authentication type. We will be opting for the password method which is ideal if there is a single person accessing the VM. Enter a suitable username and password.
  • You might be wondering what SSH public key is. A simple explanation would be to say that an SSH key relies upon the use of two related keys, a public key and a private key, that together create a key pair that is used as the secure access credential to your VM. The private key is secret and is known only to by you, the user and should be encrypted and stored safely. The public key can be shared freely with any SSH server (you’ll learn about this later in this guide) to which the user wishes to connect. The possession of this key is proof of the user’s identity. The SSH key validation method is ideal when you have a lot of people accessing your cloud application, for example employees who work in a company and need access to the cloud. These keys are normally managed by an organization’s IT team, or better yet, with the help of a trusted Certificate Authority (CA) to ensure they are stored safely.
  • Our next field is for Inbound ports. Select ‘Allow selected ports’ for the ‘Public inbound ports’ option and select ‘SSH (22)’ for ‘Select inbound ports’. We need to keep this port open to be able to access our VM once it is deployed. More details about SSH are ahead in this article after we deploy our VM.
  • Select the ‘Next: Disks’ option on the bottom of the page.
  • You will be given options to configure your OS disks and add some extra storage as well. Now, here you need to remember that your VM will have a minimum of 2 storage disks: 1 for the OS and another temporary storage. Usually, people will prefer to add more disks on top of these two because they offer very low space combined (somewhere around 30GB usable). For the OS disk type, you can choose any option of your choice (Azure recommends Premium SSD). While SSDs are faster, HDDs traditionally offer more storage capacity and are generally cheaper so you might want to go with that for now.
  • For encryption type (how to encrypt data stored in disks), I will select the option with a platform managed key for encryption. You can also choose to manage encryption at the level of each managed disk, with your own keys through the customer managed key option. By choosing a platform managed key, is generally hassle-free meaning one less thing you need to worry about and that is why I chose it.
  • Since we haven’t configured an Availability Zone, the Ultra Disk compatibility option is not available for us. Having Ultra Disk compatibility enables you to have a higher Input/Output per sec rate which leads to better performance.
  • (Optional but recommended) To create a new disk for your VM, select the ‘Create and attach a new disk option’.
  • You will be directed to the ‘Create a new disk’ page. You will have a default disk name ready which you can change.
  • If you are not importing any data through snapshots or Storage blobs, select the ‘None’ option for ‘Source type’.
  • You can select ‘Change size’ under the size option and configure the storage type and space of the disk.
  • Select platform managed key for the encryption type and select ‘no’ for ‘Enable shared disk’ (Select yes if you want this disk to be shared by multiple VMs simultaneously). Click on the OK button at the bottom of the screen once done.
  • A LUN (logical unit number) is a unique identifier used to designate individual or collections of hard disk devices. If you’ve ever owned a computer running the Windows OS, you might’ve seen drives identified with alphabetical letters. You can think of this as something similar to that.
  • You can enable caching options for your disk which improves performance. Since I do not require it for now, I will select ‘None’.
  • Under the ‘Advanced’ drop-down, you have the option to use managed disks (Azure can’t scale your storage automatically if you uncheck this option) and Ephemeral OS disks which enables you to save data on the VM itself and not as an Azure resource.
  • Select the ‘Next: Networking’ option at the bottom of the screen.
  • You will see that the Virtual Network, Subnet and Public IP options will be assigned by default. What do these 3 options mean? The Public IP option should be the most obvious among the 3. We will use a generated IP address to connect to our VM later on. Virtual Networks are something that your VM will use to connect to the Azure Resources (like Storage) assigned to it. Subnets are pretty much subsets of your Virtual Network. Partitioning different Azure resources into different subnets pretty much makes your Virtual Network clutter-less and organized. Different subnets (basically your Azure resources) are able to interact with each other. In order to monitor the activity and direct network traffic from and to different subnets and your VM, we need to put up some firewalls.
  • Your next option would be the ‘NIC network security group’ option. Network Security Group or NSGs are what help us set firewalls be defining certain rules for inbound and outbound traffic. Set this parameter to ‘Basic’ for now.
  • You will then see a couple of options for inbound ports. Configure it in the same way we had earlier.
  • Your next option will be ‘Accelerated Networking’. Enabling this option will lead to low network latency which means that your network can now send and receive high amounts of data with minimal delay, which in very, very simple terms means that your network will be faster.
  • Your next option will be to enable Load Balancing. Imagine you recently had a business idea and decided to make a website so that people can access the service you provide. Initially people might hardly ever visit your website, but for some reason a lot of people suddenly realize how amazing your service is and a lot of people start visiting your website. The server where you’ve hosted your business won’t be able to cater to more than a certain number of people at a time and if that limit is crossed, your server will crash. To prevent this, the load balancing service automatically replicates your services and hosts them on another server(s). It then places a Load Balancer in between the path from the customer to the server to direct the customer to the least busy server. Your customers can now access your website on another server which isn’t as busy and can have a smooth experience.
  • We won’t be using a load balancer as we are only going to host a VM and not a service on the VM, so make sure that you uncheck this option.
  • Select the ‘Next: Management’ option at the bottom of the screen.
  • The Monitoring options are pretty straightforward and we will select the recommended options for boot diagnostics and will not enable OS guest diagnostics because we aren’t really running anything in our VM.
  • Under ‘Identity’, you will have the ‘System assigned managed identity’ option which, to put it in simple terms, will assign a certain identity (that the system is using Azure services) to every system that your company uses. Using the Azure Active directory (Azure AD) and RBAC (Role-Based Access Control) options, you will be able to control how much access each system or account has to information and services within the Azure Subscriptions. For now, we won’t be using either of these since there is only 1 user and not a company. Make sure both the options are unchecked.
  • You will then have the Auto-Shutdown options which is fairly easy to understand and to configure. You can leave it at the default settings for now.
  • You will then have an option to enable a backup service for your data. Backing up your data is a good practice and is something that you should always do. Remember that enabling a backup will also cost you more as you are using additional resources. Since I’m not going to store any data on my VM, I will not enable backup.
  • You then have the option to control updates to your Ubuntu OS. Enabling automatic VM guest patching eases update management by safely and automatically patching virtual machines to maintain security compliance. I will select the default patch options for the Ubuntu image.
  • Select the ‘Next: Advanced’ option at the bottom of the screen.
  • You can add features like antivirus protection, server monitoring, cloud workload protection etc. through the Extensions options. I will choose to not install any extensions as I don’t need it in my VM.
  • You can add custom data to your VM while it is being provisioned through a cloud-init script. It is out of the scope of this guide. You can learn more about this here. For this tutorial, I will leave this field blank.
  • You can similarly also add User data to your VM. It is out of the scope of this guide. Read more about it here. For this tutorial, you can leave this option unchecked.
  • You can also create a dedicated server for your VMs through Azure Dedicated Hosts which typically helps you get lower latency and gives you options to control platform management among other options. You can read more about it here.
  • To achieve low latency in your VM, you can place your resources in a Proximity placement group which is s a logical grouping used to make sure that Azure compute resources are physically located close to each other. For this tutorial, don’t place your VM in any Proximity placement group as it isn’t necessary for the purpose of this tutorial.
  • You also have the option of choosing your VM generation. Gen 2 typically offers some extra features, which you don’t need for this tutorial so select Gen 1.
  • Select the ‘Next: Tags’ option at the bottom of the screen.
  • Tags can be used to logically organize your Azure resources. For example, you can apply the name ‘Application Server’ and the value ‘Testing’ to all the resources that you use in testing. You can read more about Tags here. You can leave this field blank.
  • Select the ‘Next: Review + Create’ option at the bottom of the screen.
  • Once Azure finishes running the final validation for your VM configurations, you can view the cost of your VM, creation terms as well as other configuration options in the ‘Review + Create’ tab.
  • Once you finish reading all of them and cross checking your configuration, click on the ‘Create’ option at the bottom of the screen.
  • Your VM will now start deployment and should be ready within a couple of minutes. You can go to notifications tab and click on ‘Deployment in progress…’ to view the deployment status.

Congratulations, you just created a Virtual Machine on Azure!!!!

After you are done using your VM, close it and (I cannot stress this point enough but) DO NOT FORGET TO STOP YOUR VM ON AZURE! If you don’t stop your VM then you will be billed for the entire time you don’t use your VM as well (which means the time after you shut down you VM).

Next Steps

To proceed further with what you learnt, you can learn how to

  1. Connect to your VM via SSH
  2. Establish an RDP connection to your VM

--

--

Nihal Dias

Just your run-of-the-mill Software Developer who's also an anime fanatic. I write about Software Development, Cloud Computing and Machine Learning.