How to create an Ubuntu Virtual Machine in Azure Cloud

Azure Virtual Machine (VM) is one of the types of on-demand, scalable computing resources. It gives us the flexibility of virtualization. We do not need to buy and maintain the physical hardware, we just need to take care of the machine itself. We can easily and quickly create a virtual machine with specific configurations as per our needs. The size of the VM that we use is determined by the workload that we want to run. We can connect Virtual machines in an Azure virtual network easily to our organization's network.

Azure provides many operating systems images that can be used to create Virtual Machines.

The Virtual Machine can have a public IP address assigned to it to access it remotely. The Virtual Machine needs to be created in the Virtual Network in Azure. To create a VM, we need to select a location from the list. 

With Azure Virtual Machine we need to pay for compute capacity, with no long-term commitment or upfront payments.

Pre-requisites

  1. Azure Account (Create if you don’t have one). 

What will we do?

  1. Login to Azure.
  2. Create a Virtual Machine.
  3. Connect to the Virtual Machine
  4. Delete the Virtual Machine 

Login to Azure

Click here to go Azure portal and click on Sign in.

Login to Azure

Use your credentials to log in to the account.

Sign-in

You will see the main page as follows once you successfully log in to your account. Click on 3 lines near "Microsoft Azure" in the upper left-hand corner of the Azure portal to show the portal menu.

Microsoft Azure

Create a Virtual Machine in Azure Cloud

Click on "All services" in the left panel.

All Services

You will see a screen with all the services, click on Compute - > Virtual Machine.

Compute Services

Click on "Add" to create your first Virtual Machine.

Add VM

Here, for Resource Group click on create new, enter my-resource-group name and then select OK.

Name the virtual machine as "my-first-vm", select the region "Central US", Change the Size as required, add "Username" and "Password" which will be used to login to the Virtual Machine. Click on "Next: Disk".

Resource group

Keep this configuration unchanged and click on "Next: Networking".

Networking

Here, the Virtual Network will be created by default for this Virtual Machine, if you already have your Virtual Network you can select it.

Keep the other configuration as is and click on "Next: Management".

Management

Proceed with the default configuration, click on "Next: Advanced".

Advanced VM settings

Click on "Next: Tags" to proceed with the default configuration.

Default configuration

Add "environment: test" tag here.  You can add more tags of your choice. Click on "Next: Review + create"

Review settings and create Virtual machine

You will see an error as "Validation failed. Required information is missing or not valid." To fix this error, go to the "Management" tab with a red-colored dot on it.

VM Creation error

Here the error says that "No existing storage account in current subscription and location".

The reason for this is:  We have enabled "" for which "Diagnostics storage account" is needed to Metrics are written so you can analyze them with your own tools.

To get rid of this error for now "keep Boot diagnostics as off" and click on the "Review + create" tab.

Disable Boot diagnostics

Now you can see the message "Validation passed".

Validation passed

Wait for some time and once the deployment is complete, click on "Go to resources".

Create Ubuntu VM in Azure

Here, you can see that the Virtual Machine is ready. Click on "Resource group" to see what all resources have been created under the resource group we created as part of the Virtual Machine creation process.

VM Dashboard

You can see that there are multiple resources that have been created upon creating the Virtual Machine. All these resources belong to the Virtual Machine we created.

VM Resources overview

Connect to the Virtual Machine

To connect to the Virtual Machine we created, go back to the "Overview" page of the Virtual Machine.

Connect to VM

Click on "Connect" -> "SSH".

Connect by SSH

You will see the connection details under "SSH" to connect to the Virtual Machine. Copy the IP from here.

VM IP address

Go to the terminal on your machine, type the ssh command as. "ssh username@IP". Enter the password when prompted. 

You will see the output as follows when you successfully connect to the Virtual Machine from the terminal.

SSV connect to VM

Delete the Virtual Machine

When you no longer need the Virtual Machine, you can delete it by deleting the Resource Group under which we created it.

Type the Resource Group name in the text box and click on "Delete".

When you delete the Resource Group, all the resources which belong to it will get deleted. 


Since the Resource Group we created does not have any other resources it is safe to delete it, but if there were other resources in it, we should avoid deleting the resources group as it will delete other resources too.

Delete VM on Azure

Conclusion

In this article, we learn to create our very first Virtual Machine on Azure Cloud. We saw how to fix the error we encountered while creating the machine. We also saw the steps to connect and delete the machine when it is no longer needed.

Share this page:

0 Comment(s)