What is Virtual Machine in Azure?

Description of the image

Designers and developers often work with systems that require a lot of CPU and storage power. This is because the development and deployment of apps, video editing, batch processing, machine learning, etc., require a lot of energy from the hardware. However, Azure’s Virtual Machines are an excellent alternative for professionals to work with. In Azure, a Virtual Machine (VM) is a service that allows you to create and work with virtual machines on the cloud.

Introduction - Virtual Machine in Azure

To understand in simple terms, a virtual machine in Azure is like the name suggests - it is a virtual setup on the cloud that you can use just like your physical PC. In this digital version, you can choose the specifications like CPU, memory, etc., similar to that on your laptop or personal computer. 

Microsoft refers to virtual machines as "software-defined computers" that exist within physical servers, basically just as codes. These on-demand services are created using the concept of virtualization of hardware. As a service listed under Azure's Infrastructure-as-a-Service (IaaS), virtual machines can be made as per the user's needs, and the fee for these machines is determined by the storage size and other factors.

Different Sizes in Azure Virtual Machine

In the VM service offered by Azure, it is crucial to choose the right storage size to work efficiently on the cloud. Based on the workload on the virtual machine, you should pick the size of the machine. Here are some of the different types of machines and sizes Azure offers.

  1. General Purpose: The sizes for general purpose machines include B-series, D-series, and E-series. These sizes are used for hosting web servers, handling small and medium-sized databases, and developing and deploying applications. These virtual machines have a balanced CPU-to-memory ratio.
  2. Compute Optimized: The compute-optimized virtual machines are used for processes that require a lot of CPU energy. For example, batch processing and batch coding are some of the activities done on these VMs. H-series, F-series, and M-series sizes are used for compute-optimized VMs.
  3. Memory Optimized: While compute-optimized VMs are for CPU-intensive tasks, memory-optimized is for memory-intensive activities like machine learning and in-memory analytics. The ratio here leans towards more memory - the M-series, G-series, and GS-series sizes are suitable for these tasks.
  4. Storage Optimized: As the name suggests, these VMs are for storage-intensive tasks - big analytics and data warehousing fall under this category. The storage to CPU and memory ratio is high, making them the perfect choice for these tasks. The L-series and H-series sizes are used for storage-optimized VMs.
  5. GPU Optimized: These VMs are made for high-density graphical workings and video workloads, making them computer-intensive. The N-series is used for GPU-optimized virtual machines to manage the dense workload.

The hourly charges are calculated based on the VM size and the operating system that the user is utilizing.

Uses of Virtual Machine in Azure

Azure VMs are utilized for various purposes like deploying apps on the cloud, testing new operating systems, and accessing corrupted data. Here are a few other uses of virtual machines in Azure.

Building Applications

A main chunk of users who utilize Azure VMs are software developers. Virtual machines provide you with the perfect environment to develop and deploy an application. Since you can pick your own operating system, you can create apps for any OS and test them to see their effectiveness.

Disaster Recovery Cases

One of the most outstanding features of virtual machines is that users can back up their OS data on a virtual machine for future use. This comes in handy in disaster recovery cases and cases of file corruption. Backing up your data on a virtual machine can be a game-changer as you can ensure that all the necessary information stays safe.

Managing Dense Workloads

Users prefer virtual machines because they can select the desired CPU, storage, and memory requirements to manage high workloads. This feature is handy for designers and developers who work remotely - by creating VMs that handle high-density workloads, they can manage their designs from remote locations.

Trial for New OS

Azure VMs can be used to try new operating systems you want to install on your physical setup. By exploring the positives and negatives in terms of the performance of the OS in the virtual machine, you can determine whether you want actually to install it on your device.

Advantages of Using Azure Virtual Machines

Virtual Machines in Azure are like individual computers but without the hardware. This makes the service a convenient one for users across the world to operate them on cloud simply. Virtual machines boast many advantages, as briefed below.

  • Cost efficiency - Using a single virtual machine, you can run multiple projects and tasks, thus saving costs used for physical infrastructure. Down the road, it also saves maintenance costs.
  • Scalable - A great feature of VMs is that you can distribute workload among other virtual machines. By doing so, you can quickly scale the applications you have developed and increase their performance.
  • Agile - Virtualization increases the speed of the processes undertaken in VMs. Setting up and managing a virtual machine definitely takes less time compared to your PC.
  • Secure - As virtual machines run on the cloud, the security benefits are better compared to their physical counterparts. 

Useful Commands of Virtual Machines in Azure

Basic VM Management

1. Create a VM

az vm create --resource-group myResourceGroup --name myVM --image UbuntuLTS --admin-username azureuser --generate-ssh-keys

2. List VMs

az vm list --resource-group myResourceGroup --output table

3. Delete a VM

az vm delete --resource-group myResourceGroup --name myVM

VM Operations

1. Start a VM

az vm start --resource-group myResourceGroup --name myVM

2. Stop a VM

az vm stop --resource-group myResourceGroup --name myVM

3. Restart a VM

az vm restart --resource-group myResourceGroup --name myVM
Resize a VM
az vm resize --resource-group myResourceGroup --name myVM --size Standard_DS3_v2
Changes the size of the specified VM.
Add a Data Disk
az vm disk attach --resource-group myResourceGroup --vm-name myVM --name myDataDisk --new --size-gb 100
Attaches a new data disk to the specified VM.
Configure NIC
az network nic update --resource-group myResourceGroup --name myNIC --ip-configurations myIPConfig --public-ip-address myPublicIP
Updates the network interface configuration of a VM.
Update VM Tags
az vm update --resource-group myResourceGroup --name myVM --set tags.Owner=MyName
Updates the tags of the specified VM.
Enable Accelerated Networking
az network nic update --resource-group myResourceGroup --name myNIC --accelerated-networking true
Enables accelerated networking for a VM's NIC.
Change OS Disk Size
az vm update --resource-group myResourceGroup --name myVM --os-disk-size-gb 128
Changes the size of the OS disk for the specified VM.
Configure Boot Diagnostics
az vm boot-diagnostics enable --resource-group myResourceGroup --name myVM --storage myStorageAccount
Enables boot diagnostics for a VM.
Set Static IP Address
az network nic ip-config update --resource-group myResourceGroup --nic-name myNIC --name ipconfig1 --private-ip-address
Sets a static IP address for a VM's NIC.
Attach Existing Data Disk
az vm disk attach --resource-group myResourceGroup --vm-name myVM --disk myExistingDisk
Attaches an existing data disk to the specified VM.
Detach Data Disk
az vm disk detach --resource-group myResourceGroup --vm-name myVM --name myDataDisk
Detaches a data disk from the specified VM.
Update OS Disk
az vm update --resource-group myResourceGroup --name myVM --set
Updates the OS disk of the specified VM.
Enable Managed Disks
az vm update 
--name myVM --set<diskID>
Enables managed disks for the specified VM.
Update VM Size
az vm update 
--name myVM --size 
Updates the size of the specified VM.
Set Availability Set
az vm availability-set 
myResourceGroup --name 
Creates an availability set for VMs.
Add VM to Availability Set
az vm update --resource-group 
--name myVM --set<availabilitySetID>
Adds the specified VM to an availability set.
Configure Custom Script Extension
az vm extension set --resource-group myResourceGroup
--vm-name myVM --name 
CustomScript --publisher 
Microsoft.Azure.Extensions --settings 
'{"fileUris": ["https://path/to/"], "commandToExecute": "./"}'
Adds a custom script extension to a VM.

Pricing of Virtual Machine in Azure

Instance TypevCPUsRAM (GB)Pay-as-you-go ($/hour)1-year Reserved ($/hour)3-year Reserved ($/hour)Spot ($/hour)
D2s v528$0.096$0.060$0.043$0.029
E2s v5216$0.112$0.070$0.051$0.034
F4s v248$0.169$0.106$0.075$0.048
L8s v2864$0.504$0.318$0.224$0.144
NC4as T4 v3416$1.203$0.762$0.537$0.349

Pricing Comparison of VM in Azure With AWS EC2

Instance TypevCPUsRAM (GB)Azure Pay-as-you-go ($/hour)AWS On-Demand ($/hour)Azure 1-year Reserved ($/hour)AWS 1-year Savings Plan ($/hour)Azure Spot ($/hour)AWS Spot ($/hour)
B1s / t3.micro11$0.008$0.0104$0.005$0.007$0.002$0.0035
D2s v5 / m5.large28$0.096$0.096$0.060$0.061$0.029$0.028
E2s v5 / r5.large216$0.112$0.126$0.070$0.080$0.034$0.035
F4s v2 / c5.large48$0.169$0.085$0.106$0.054$0.048$0.028
L8s v2 / i3.large864$0.504$0.312$0.318$0.199$0.144$0.093
NC4as T4 v3 / p3.2xlarge416$1.203$3.06$0.762$2.125$0.349$0.918

Tips for optimizing costs for VM in Azure

Use Reserved InstancesCommit to a 1- or 3-year term for significant discounts. Ideal for predictable workloads.
Leverage Spot VMsUtilize unused capacity at reduced rates. Best for flexible, interruptible tasks.
Right-Size VMsRegularly review and adjust VM sizes to match workload requirements, avoiding over-provisioning.
Auto-Shutdown PoliciesSchedule automatic shutdowns during non-peak hours to save on costs.
Monitor and OptimizeUse Azure Cost Management tools to track usage, set budgets, and optimize resource allocation.
Utilize Azure Hybrid BenefitsBring your existing on-premises licenses to Azure for additional savings.

Real-World Use Cases

CompanyUse CaseDetailsBenefits
GEICOEnhanced Customer Experience and Operational EfficiencyGEICO migrated web applications to Azure VMs to improve digital customer experience.Better scalability and performance, faster response times, improved disaster recovery.
AdobeScaling Creative Cloud ServicesAdobe used Azure VMs to scale Creative Cloud services for millions of users.Improved scalability, reduced latency, and consistent high-performance experience.
BMWDeveloping Connected Car SolutionsBMW adopted Azure VMs to enhance vehicle telematics and infotainment systems.Real-time data processing, advanced analytics, improved diagnostics, and predictive maintenance.
MyntraSupporting E-commerce GrowthMyntra leveraged Azure VMs to handle high traffic during peak shopping seasons.Efficient workload management, responsive platform, better cost management.
HeinekenGlobal Marketing CampaignsHeineken used Azure VMs for global marketing campaigns requiring significant compute resources.Quick deployment, real-time data processing, targeted marketing efforts.


Azure Virtual Machine is a service offered by Azure that provides higher CPU and storage power to work in virtual environments. VMs are also known as software-defined computers, these machines offer the exact same purpose as a PC but without the hardware. They operate on Azure cloud and are easy and efficient to manage. You can choose different types of VMs with varying storage sizes to fit your activities. Virtual machines are used to build and test applications, manage high workloads, and perform other purposes. Due to its agility, increased security, and portability, Azure Virtual Machine is widely used by developers worldwide.

Read More

Follow us on

Table of Contents

    Subscribe to Us

    Always Get Notified