Constructing Azure Virtual Machine

In this article, we will explore about the virtual machines, step by step implementation, and the ways of connecting VMs with our local system.

Introduction

In this article, we will explore what a Virtual Machine is, along with the step by step implementation and the ways of connecting VMs to our local system.

Virtual Machines Service in Azure provides a highly flexible "compute on demand" option for running our application workloads. The Azure portal provides a large collection of templates from which we can get started with our desired server and operating system. We can create multiple virtual machines and group them together in Azure cloud services. Cloud services serve as a network and security boundary for virtual machines. By placing virtual machines in cloud service, we can create multiple instances of any tier of our application. For example, we host our web application on three virtual machines having the same server operating system and place those virtual machines in an availability set so that at least one virtual machine will be available at all the times. Virtual machines use the Hyper-V virtual hard disk format (.vhd) for their hard drives. We can simply upload the fixed-size virtual hard disk files from our infrastructure to Azure and also download the hard disk files from Azure to our data center.

Let's create a Virtual Machine through the portal.

Log into portal.azure.com and click on "Virtual machines".

Construct Azure Virtual Machine 

Click on 'Add', which will open the "Create a virtual machine" wizard.

Construct Azure Virtual Machine 
  1. Select your Azure subscription. Duly note that all resources in an Azure subscription are billed together.
  2. Select existing or create a new resource group. It is a collection of resources that share the same lifecycle, permissions, and policies.
  3. Provide your virtual machine a name. For demo purpose, I have given it a name like 'MyFirstVM'.
  4. Select the region that is right for you and your customers. Not all VM sizes are available in all regions.
  5. Azure offers a range of options for managing the availability and resiliency of your application. We can select 'Availability Set' also but as of now, select 'No infrastructure redundancy required'.
  6. Choose the base operating system or application for your VM.
  7. Change the size as per your requirement and the price will be calculated accordingly.
  8. Provide Username and Password which will be used later on to connect your VM.
  9. Inbound Port Rules can be added later on. As of now, select 'None'.
  10. Select 'No' for a Windows license.

    Construct Azure Virtual Machine

    Construct Azure Virtual Machine

    Construct Azure Virtual Machine
  1. Select your disk option.

    1. Premium SSD
      Offers high-performance, low-latency disk support for I/O-intensive applications and production workloads. 

    2. Standard SSD
      Cost effective storage option optimized for workloads that needs consistent performance at lower IOPS (Input/Output Operations Per Second) levels.

    3. Standard HDD
      For dev/test scenarios and less critical workloads at the lowest cost.
  1. For best performance, reliability, scalability, and access control, it is recommended to select Managed Disk for most of the virtual machine configuration. Use unmanaged disks if you need to support certain classic scenarios or want to manage Disk VHDs in your own storage account.

    Construct Azure Virtual Machine
  • Keep the networking option as it is and move to Management.

Construct Azure Virtual Machine

Construct Azure Virtual Machine
  1. Boot the diagnostics capture serial console output and screenshots of the virtual machine running on a host to help diagnose startup issues.
  2. OS guest diagnostics gets metrics every minute for our virtual machine. We can use them to create alerts and stay informed on our applications.
  3. Metrics are written on a storage account.
  4. If Identity is enabled, all necessary permissions can be granted via Azure Role-based access control.
  5. Enable auto-shutdown configures our virtual machine to automatically shut down daily.
  6. Provide the time when we want to shutdown VM
  7. Provide the time zone in which shutdown time is given
  8. Subscribe for notification before the VM is shutdown
  9. To guard our VM against accidental deletion and corruption, enable backup.
    Construct Azure Virtual Machine

    Construct Azure Virtual Machine
  1. Add extensions like antivirus protection for our VM.

    Construct Azure Virtual Machine
  1. A tag is not required as of now. Skip this stage and move to Review + Create.

    Construct Azure Virtual Machine
  1. It will validate all the inputs and show the status message.
  2. Click on the 'Create' button.

    Construct Azure Virtual Machine

    Construct Azure Virtual Machine

    Construct Azure Virtual Machine

Once the VM is created, you will be able to see the deployment details as below.

Construct Azure Virtual Machine 

Now, in the next step, let's try to connect our recently created VM. For this, we need a public IP Address and port or we can download the RDP file directly.

  1. Click on 'MyFirstVM' resource.
  2. Click on 'Connect'.

    Construct Azure Virtual Machine
  1. Click on 'Download RDP File' button.

    Construct Azure Virtual Machine

You will get the file as below in your local system.

Construct Azure Virtual Machine 

Now, if you try to connect VM using the above RDP file, it will throw an exception. By default, all the inbound ports are blocked. We need to add a new rule to enable the particular port. 

Explore the 'Networking' option under Settings.

Click the 'Add Inbound port rule' button.

Construct Azure Virtual Machine 

Input 3389 as the destination port ranges and keep the rest of other options as they are.

Click on the 'Add' button.

Construct Azure Virtual Machine 

Once the inbound port is added, try again to connect to the VM. It will ask for credentials.

Insert the credentials which we have given at the time of VM creation.

Construct Azure Virtual Machine 

Connecting…

Construct Azure Virtual Machine 

It will give warnings for Certificate but as of now, you can click on 'Yes' button and continue.

Construct Azure Virtual Machine 

We are successfully able to connect our VM.

Construct Azure Virtual Machine 

We can monitor our VM CPU, Network, and Disk details as well as Start and Stop VM as per our requirement.

Construct Azure Virtual Machine