← Back to Articles         
Azure Virtual Machines Complete Guide

Azure Virtual Machines Complete Guide

Published on 14 Oct 2026     26 min read Microsoft AZURE
Azure Virtual Machines

Azure Virtual Machines Explained: VM Sizes, Pricing, Storage, Networking & Hands-On Deployment

Introduction

Azure Virtual Machines (VMs) are one of the most important compute services in Microsoft Azure. They allow organizations to run Windows and Linux servers in the cloud without purchasing or maintaining physical hardware.

Whether you want to host an ASP.NET Core Web API, deploy an IIS website, run a database server, or create a development environment, Azure Virtual Machines provide flexible computing resources.

In this article, we will explore Azure Virtual Machines from fundamentals to practical implementation, including creating Ubuntu and Windows Server VMs, configuring networking and storage, connecting remotely, and controlling costs.

What You'll Learn

  • What Azure Virtual Machines are and how they work

  • VM series, sizes, and workload selection

  • Pay-as-you-go, Reserved Instances, and Spot pricing

  • Operating system images and Azure Marketplace

  • Managed Disks, OS disks, data disks, and temporary disks

  • Public IP addresses, private IP addresses, and DNS labels

  • Network Security Groups (NSGs)

  • Creating an Ubuntu VM using Azure Portal

  • Connecting to Linux VMs using SSH

  • Formatting and mounting additional data disks

  • VM lifecycle: Running, Stopped, and Deallocated

  • Creating Windows Server VMs and connecting using RDP

  • Azure VM cost optimization and security best practices

  • Important Azure VM interview questions and answers


1. What Is an Azure Virtual Machine?

An Azure Virtual Machine is a software-defined computer running on physical hardware in a Microsoft-managed data center.

It provides virtualized computing resources such as:

  • CPU (vCPU)

  • Memory (RAM)

  • Operating system

  • Storage

  • Network connectivity

Azure VMs are an example of Infrastructure as a Service (IaaS).

Microsoft manages the physical infrastructure, while customers manage the operating system, applications, and most guest-level configurations.

Azure VM Architecture

             Microsoft Azure Data Center
                         |
                Physical Server
                         |
                    Hypervisor
                         |
          +--------------+--------------+
          |              |              |
          v              v              v
        VM 1           VM 2           VM 3
       Ubuntu         Windows         Linux
          |              |              |
       1 vCPU          2 vCPU         4 vCPU
       1 GB RAM        4 GB RAM      16 GB RAM
          |              |              |
       OS Disk        OS Disk        OS Disk
          |              |              |
       Web App         IIS App        Database

The hypervisor isolates virtual machines and allocates physical hardware resources.

What Does Microsoft Manage?

  • Physical servers

  • Data center infrastructure

  • Hypervisor

  • Hardware maintenance

  • Physical networking

  • Power and cooling

What Does the Customer Manage?

  • Operating system configuration

  • Guest OS updates and security patches

  • Applications and services

  • Network access rules

  • Data and backups

  • User access and authentication

Azure provides infrastructure recovery capabilities, but automatic migration of every VM during a hardware failure is not guaranteed. Applications requiring high availability should use appropriate redundancy architectures.

Example

A company wants to host an ASP.NET Core Web API on Windows Server.

Instead of purchasing a physical server, it can create an Azure Windows VM, install IIS and the .NET Hosting Bundle, and deploy the application.

Key Points

  • Azure VM is an IaaS compute service.

  • Supports Windows and Linux.

  • Provides operating system-level control.

  • Suitable for legacy and custom applications.

  • The customer remains responsible for guest OS management.


2. Azure VM Series and Sizes

Azure provides different VM families optimized for different workloads.

A VM size determines:

  • Number of vCPUs

  • Available memory

  • Storage capabilities

  • Network performance

  • Compute cost

Common Azure VM Series

Series Category Recommended workloads
B-Series Burstable Development, testing, lightweight websites
D-Series General purpose Web applications, APIs, application servers
E-Series Memory optimized Databases, caching, memory-intensive applications
F-Series Compute optimized Batch processing, CPU-intensive applications
L-Series Storage optimized NoSQL databases, storage-intensive applications
N-Series GPU optimized AI, machine learning, graphics processing
H-Series High-performance computing Scientific simulations and engineering workloads
M-Series Large-memory workloads SAP HANA and enterprise databases

Example VM Sizes

VM Size vCPU RAM Typical usage
Standard_B1s 1 1 GiB Learning, small Linux workloads
Standard_B2s 2 4 GiB Small development applications
Standard_D2s_v3 2 8 GiB Web applications
Standard_D4s_v3 4 16 GiB Application servers
Standard_E2s_v3 2 16 GiB Memory-intensive workloads
Standard_F2s_v2 2 4 GiB Compute-intensive workloads

These are representative sizes. Availability depends on region, subscription, and current Azure offerings.

Understanding VM Size Naming

Example: Standard_D2s_v3

Standard_D2s_v3
   |     | ||  |
   |     | ||  +-- Version 3
   |     | |+----- Premium storage capable
   |     | +------ 2 vCPUs
   |     +-------- D-Series (General Purpose)
   +-------------- Standard VM family prefix

The version identifies a VM family generation; newer generations are not automatically the best value for every workload.

How to Choose the Right VM?

For a small development application, start with a B-Series VM.

For a production ASP.NET Core application, consider a D-Series VM based on actual CPU, memory, and availability requirements.

For memory-intensive databases, evaluate an E-Series VM.

Key Points

  • B-Series supports burstable CPU performance using credits.

  • D-Series balances CPU and memory.

  • E-Series provides more memory per vCPU.

  • F-Series focuses on compute performance.

  • Select sizes using workload metrics rather than assumptions.


3. Azure VM Pricing Models

Azure provides several pricing options to optimize compute costs.

3.1 Pay-As-You-Go

Pay only for the compute resources used, without a long-term commitment.

Best for:

  • Development environments

  • Testing

  • Short-term workloads

  • Unpredictable usage

Advantages:

  • No long-term commitment

  • Flexible provisioning

  • Easy scaling

Disadvantage:

  • Higher compute price than eligible discounted options

3.2 Azure Reserved VM Instances

Reserved VM Instances provide discounted compute pricing in exchange for a one-year or three-year commitment.

Best for:

  • Stable production environments

  • Predictable workloads

  • Long-running enterprise applications

Advantages:

  • Lower compute costs

  • Predictable commitment

  • Potentially significant savings

Important: A reservation is a billing discount, not a guarantee of VM capacity. Actual savings depend on the VM, region, operating system, and reservation terms.

3.3 Azure Spot Virtual Machines

Spot VMs use unused Azure compute capacity at discounted prices.

Azure can evict Spot VMs when capacity is needed or when a configured price threshold is exceeded.

Best for:

  • Batch processing

  • Rendering

  • Testing

  • Fault-tolerant background jobs

Not recommended for:

  • Critical production databases

  • Applications requiring uninterrupted availability

  • Stateful services without recovery mechanisms

Pricing Comparison

Feature Pay-As-You-Go Reserved VM Spot VM
Commitment None 1 or 3 years None
Cost Standard rate Discounted Deeply discounted
Availability Standard provisioning Standard provisioning Subject to eviction
Suitable for Variable workloads Predictable workloads Interruptible workloads

Azure Hybrid Benefit

Eligible organizations can use existing Windows Server or SQL Server licenses to reduce Azure licensing costs, subject to Microsoft's licensing conditions.

Key Points

  • Pay-as-you-go provides maximum flexibility.

  • Reservations reduce costs for predictable usage.

  • Spot VMs are interruptible.

  • Disk, networking, and licensing costs may be separate.

  • Always estimate costs using Azure Pricing Calculator.


4. Operating Systems and Azure Marketplace

Azure supports Windows and Linux operating systems.

Common Operating Systems

Operating System Common usage
Windows Server 2022 IIS, .NET applications, enterprise workloads
Windows Server 2025 Modern Windows Server workloads
Ubuntu Server 24.04 LTS Linux hosting, APIs, containers
Debian Linux applications
Red Hat Enterprise Linux Enterprise Linux workloads
SUSE Linux Enterprise Enterprise workloads
Oracle Linux Oracle-oriented workloads

What Is Azure Marketplace?

Azure Marketplace provides preconfigured images and solutions that can be deployed directly into Azure.

Examples include:

  • Ubuntu Server

  • Windows Server

  • WordPress images

  • Nginx-based solutions

  • Security appliances

  • Enterprise application images

Marketplace images can include additional software or licensing charges.

Generation 1 vs Generation 2

Generation 1 Generation 2
Legacy BIOS UEFI
Legacy compatibility Modern boot architecture
Older workload support Supports modern security features
More limited OS disk capabilities Supports larger OS disks on eligible configurations

Recommendation: Prefer Generation 2 for new VMs when supported by the selected image and size.


5. Azure Managed Disks

Azure Managed Disks provide persistent block storage for virtual machines.

Azure manages the underlying storage infrastructure, allowing users to select disk capacity, performance, and redundancy without managing storage accounts directly.

Types of VM Disks

                 Azure Virtual Machine
                          |
             +------------+------------+
             |            |            |
             v            v            v
          OS Disk      Data Disk   Temporary Disk
             |            |            |
        Operating      Application   Temporary
          System          Data         Files
             |            |            |
        Persistent     Persistent     Ephemeral

5.1 OS Disk

The OS disk contains the operating system and required system files.

Examples:

  • Windows: C:

  • Linux: /

It is required for standard Azure VMs.

5.2 Data Disk

A data disk provides additional persistent storage.

Common uses:

  • Database files

  • Application data

  • Logs

  • Uploaded documents

Data disks can be retained independently of a VM, depending on deletion settings.

5.3 Temporary Disk

Some Azure VM sizes provide temporary local storage.

Characteristics:

  • Low-latency storage

  • Intended for temporary files

  • Data may be lost during maintenance, redeployment, or deallocation

  • Not available on every VM size

Never use temporary disks for critical application data.

Azure Managed Disk Types

Disk Type Performance Recommended use
Standard HDD Low Development, infrequent access
Standard SSD Moderate Web servers, development and testing
Premium SSD High Production applications and databases
Premium SSD v2 Configurable high performance Demanding production workloads
Ultra Disk Very high High-performance databases

Disk IOPS, throughput, latency, and supported sizes depend on the specific disk SKU and VM capabilities.

Key Points

  • OS disks store operating systems.

  • Data disks store persistent application data.

  • Temporary disks should never store critical data.

  • Managed disks are the recommended default.

  • Persistent disks may continue to incur charges after VM deallocation.


6. Azure VM Networking

Azure VMs use virtual networking resources to communicate with other systems.

Common components include:

  • Virtual Network (VNet)

  • Subnet

  • Network Interface (NIC)

  • Private IP address

  • Public IP address

  • Network Security Group

VM Networking Architecture

                   Internet
                       |
                       v
                 Public IP
                       |
                       v
                Azure Network
                       |
                       v
              Virtual Network
                10.0.0.0/16
                       |
                       v
                    Subnet
                10.0.0.0/24
                       |
                       v
                NSG Rules
                       |
                       v
                Network NIC
                       |
                       v
                  Ubuntu VM
                10.0.0.4

Private IP Address

A private IP address allows communication inside an Azure virtual network and connected private networks.

Example: 10.0.0.4

Public IP Address

A public IP address allows communication over the internet, subject to routing and security rules.

Example: 20.84.x.x

Static vs Dynamic Public IP

Static IP Dynamic IP
Remains allocated until explicitly released or deleted May change after deallocation
Useful for DNS and allowlists Useful for temporary environments
Predictable endpoint Address persistence not guaranteed

Important: Standard SKU public IP addresses use static allocation. Current Azure Portal options may differ from older tutorials that demonstrate dynamic Basic SKU public IPs.

DNS Labels

Azure can assign a DNS name to a public IP resource.

Example:

ubuntu-demo.eastus.cloudapp.azure.com

The DNS name resolves to the public IP resource's address.


7. What Is a Network Security Group (NSG)?

A Network Security Group controls inbound and outbound network traffic using security rules.

An NSG operates primarily at network and transport layers, evaluating properties such as source, destination, protocol, and port.

NSG Traffic Flow

                  Internet
                      |
                      v
                Inbound Traffic
                      |
                      v
              Network Security Group
                      |
           +----------+----------+
           |                     |
           v                     v
      SSH Port 22           RDP Port 3389
         Allow                  Deny
           |                     |
           v                     X
       Linux VM                Blocked

Important NSG Rule Properties

Property Description
Priority Lower number evaluated first
Direction Inbound or Outbound
Source Source IP or address range
Destination Destination IP or address range
Protocol TCP, UDP, ICMP, or Any
Port Network port
Action Allow or Deny

Custom NSG priorities range from 100 to 4096.

Default Inbound NSG Rules

Priority Rule Action
65000 AllowVnetInBound Allow
65001 AllowAzureLoadBalancerInBound Allow
65500 DenyAllInBound Deny

Custom rules are evaluated before default rules when they have higher precedence.

Example

For an Ubuntu VM running Nginx:

  • SSH: TCP 22

  • HTTP: TCP 80

  • HTTPS: TCP 443

For a Windows VM:

  • RDP: TCP 3389

Security Recommendation: Avoid exposing SSH and RDP to all internet addresses. Restrict access to trusted IP ranges or use Azure Bastion.

Key Points

  • NSGs control inbound and outbound traffic.

  • Lower priority numbers take precedence.

  • NSGs can be associated with subnets and NICs.

  • NSGs are stateful.

  • Both subnet-level and NIC-level rules can affect traffic.


8. Hands-On: Create an Ubuntu VM Using Azure Portal

Let's create an Ubuntu Server VM.

Cost warning: Free-account eligibility varies by subscription, offer, region, VM image, and current Azure pricing. A VM labeled B1s is not automatically free, and attached disks or public IPs can generate charges. Verify eligible services and quotas before deployment.

Step 1: Create a Resource Group

  1. Open https://portal.azure.com.

  2. Search for Resource groups.

  3. Click Create.

  4. Enter the following values.

Field Value
Subscription Your Azure subscription
Resource group vm-demo-rg
Region Your preferred region

Click Review + create, followed by Create.

A resource group logically organizes related Azure resources for management and cleanup.

Step 2: Open Virtual Machines

  1. Search for Virtual machines.

  2. Click Create.

  3. Select Azure virtual machine.

Step 3: Configure Basics

Field Value
Resource group vm-demo-rg
VM name ubuntu-demo-vm01
Region Supported region
Availability options No infrastructure redundancy required
Image Ubuntu Server 24.04 LTS — x64 Gen2
Architecture x64
Size Standard_B1s
Azure Spot Disabled

The exact security type and size options depend on the image, region, and subscription.

Step 4: Configure Administrator Account

Field Value
Authentication SSH public key
Username azureuser
SSH key source Generate new key pair
Key name ubuntu-demo-vm01_key

SSH public key authentication is recommended over password authentication for Linux administration.

Step 5: Configure Inbound Ports

Select:

  • Public inbound ports: Allow selected ports

  • Inbound port: SSH (22)

Restrict SSH access to your public IP address after deployment, or use a private access solution.

Step 6: Configure Disks

Open the Disks tab.

Field Value
OS disk type Standard SSD
OS disk size Image default
Delete with VM Enabled

Optionally create an additional small managed data disk:

  • Name: ubuntu-demo-vm01-data01

  • Source: Empty disk

  • Type: Standard HDD

  • Size: Small supported capacity

Available disk sizes and minimum billing increments vary by SKU.

Step 7: Configure Networking

Field Value
Virtual Network Create new or select existing
Subnet Default
Public IP New Standard SKU IP
NIC NSG Basic
Inbound ports SSH (22)
Load balancing None

Step 8: Configure Management

Enable Auto-shutdown, if available in the current VM creation workflow.

Example:

  • Auto-shutdown: Enabled

  • Shutdown time: 11:00 PM

  • Time zone: Your local time zone

Auto-shutdown is useful for development VMs because it releases compute allocation.

Step 9: Configure Monitoring

Enable boot diagnostics using the available managed storage option.

Boot diagnostics can help troubleshoot startup failures using console screenshots and serial log information.

Step 10: Add Tags

Name Value
Environment Learning
Project AzureVM
Owner YourName

Step 11: Review and Create

Click Review + create.

Check the selected:

  • VM size

  • Operating system image

  • Disk type

  • Public IP

  • Estimated cost

Click Create.

If Azure generates an SSH key pair, download the private key and store it securely.

Once deployment completes, click Go to resource.


9. Connect to Ubuntu VM Using SSH

SSH stands for Secure Shell.

It provides encrypted remote access to Linux servers.

SSH Connection Flow

             Windows Laptop
                   |
                   | SSH Port 22
                   | Private Key
                   v
              Public IP
                   |
                   v
             Azure NSG
                   |
              Allow TCP 22
                   |
                   v
               Ubuntu VM
                   |
             SSH Public Key
                   |
                   v
             Authentication
                   |
                   v
             Linux Terminal

Step 1: Open PowerShell

On your Windows computer, open PowerShell or Windows Terminal.

Step 2: Connect to the VM

ssh -i "C:\Users\YourName\.ssh\ubuntu-demo-vm01_key.pem" azureuser@YOUR_PUBLIC_IP

Replace YOUR_PUBLIC_IP with the address shown in Azure Portal.

Verify the SSH host fingerprint before accepting the first connection.

Step 3: Check Ubuntu Version

lsb_release -a

Step 4: Check CPU and Memory

nproc
free -h

Step 5: Check Disks

lsblk

Step 6: Check Network Information

ip addr

Step 7: Check Public Internet IP

curl ifconfig.me

The returned outbound IP may differ from the VM's assigned inbound public IP when an explicit outbound networking configuration is used.

Step 8: Exit SSH

exit

Closing the SSH session does not stop or deallocate the Azure VM.


10. Format and Mount a Data Disk in Ubuntu

After attaching a new empty data disk, Linux must identify, format, and mount it before it can be used.

Step 1: Identify the Disk

lsblk -f

Identify the new disk carefully by its size, filesystem state, and Azure device mapping.

Do not assume the new disk is always /dev/sdc. Device names can vary, especially on NVMe-enabled VMs.

Step 2: Format the New Disk

Example only, assuming /dev/sdc is confirmed to be the empty data disk:

sudo mkfs.ext4 /dev/sdc

Warning: Formatting an existing disk destroys its filesystem and can cause data loss.

Step 3: Create a Mount Directory

sudo mkdir -p /data

Step 4: Mount the Disk

sudo mount /dev/sdc /data

Step 5: Verify the Mount

df -h /data

Step 6: Configure Persistent Mounting

Find the disk UUID:

sudo blkid /dev/sdc

Add the verified UUID to /etc/fstab:

UUID=YOUR_DISK_UUID /data ext4 defaults,nofail 0 2

Test the configuration:

sudo mount -a

Using a UUID helps prevent mounting the wrong disk if Linux device names change.

Key Points

  • New empty data disks must be prepared before use.

  • Verify the correct device before formatting.

  • Use /etc/fstab for persistent mounting.

  • Prefer UUID-based mounting.

  • Back up important application data.


11. Azure VM Lifecycle: Running vs Stopped vs Deallocated

Understanding VM states is essential for controlling Azure costs.

VM Lifecycle

                 Azure Virtual Machine
                          |
                          v
                       Running
                          |
             +------------+------------+
             |                         |
             v                         v
       OS Shutdown              Azure Stop
             |                         |
             v                         v
       Stopped (Allocated)      Stopped (Deallocated)
             |                         |
       Compute Billed            Compute Not Billed
             |                         |
             +------------+------------+
                          |
                        Start
                          |
                          v
                       Running

VM State Comparison

VM State Compute Billing Disk Billing
Running Yes Yes
Stopped (Allocated) Yes Yes
Stopped (Deallocated) No Yes

Other charges, such as public IP addresses, backups, and associated services, may continue while a VM is deallocated.

Important Difference

Running the following command inside Linux normally shuts down the guest operating system:

sudo shutdown now

A guest OS shutdown does not necessarily deallocate the VM, so compute charges can continue.

Using Stop in Azure Portal normally initiates deallocation. Verify the final VM status is Stopped (deallocated).

How to Stop Compute Billing

  1. Open Azure Portal.

  2. Navigate to the virtual machine.

  3. Click Stop.

  4. Confirm the action.

  5. Verify Stopped (deallocated) status.

Key Points

  • Running VMs incur compute charges.

  • Stopped (allocated) VMs can still incur compute charges.

  • Deallocated VMs do not incur normal VM compute charges.

  • Managed disks remain billable.

  • Public IP charges may continue after deallocation.


12. Create a Windows Server VM in Azure

Azure also supports Windows Server VMs for enterprise workloads.

Typical applications include:

  • ASP.NET Framework applications

  • ASP.NET Core applications

  • IIS web servers

  • SQL Server installations

  • Active Directory Domain Services

  • Windows services

Step 1: Create a Windows VM

In Azure Portal:

Virtual machines → Create → Azure virtual machine

Step 2: Configure Basics

Field Value
Resource group vm-demo-rg
VM name windows-demo-vm01
Image Windows Server 2022 Datacenter
Size Standard_B2s or another supported size
Authentication Password
Username azureuser
Inbound port RDP (3389)

Use a strong password that meets Azure's password requirements.

Step 3: Configure Disks

Choose Standard SSD or another suitable managed disk type.

Enable Delete with VM when the VM and its disks are intended to be disposable.

Step 4: Configure Networking

Select:

  • Virtual Network

  • Subnet

  • Public IP, if required

  • Network Security Group

For RDP access, allow TCP port 3389 only from trusted source IP addresses.

For production, Azure Bastion or private connectivity is preferable to exposing RDP directly to the internet.

Step 5: Deploy

Click Review + create, validate the configuration, and deploy.

Windows VMs may incur both compute and operating system licensing charges. Free-account eligibility must be checked against the specific offer and image.


13. Connect to Windows VM Using RDP

RDP stands for Remote Desktop Protocol.

It provides graphical remote access to Windows systems.

RDP Connection Flow

             Windows Computer
                    |
                    | RDP TCP 3389
                    v
                Public IP
                    |
                    v
               Azure NSG
                    |
              Allow TCP 3389
                    |
                    v
             Windows Server VM
                    |
             User Authentication
                    |
                    v
             Windows Desktop

Step 1: Download RDP File

  1. Open the Windows VM in Azure Portal.

  2. Select Connect.

  3. Choose RDP.

  4. Download the RDP file.

Step 2: Open Remote Desktop

Double-click the downloaded .rdp file.

Alternatively, press Win + R and run:

mstsc

Step 3: Authenticate

Enter the administrator username and password created during deployment.

Verify the remote computer's identity and certificate information before trusting a connection warning.

Step 4: Explore Windows Server

Open PowerShell and execute:

ipconfig

Check the computer name:

hostname

Check the operating system:

systeminfo

Step 5: Disconnect

Close the Remote Desktop session.

Important: Disconnecting RDP does not stop the VM. The VM continues running and may continue generating charges.


14. Linux VM vs Windows VM

Feature Linux VM Windows VM
Common OS Ubuntu Windows Server
Remote access SSH RDP
Default port 22 3389
Interface Terminal Graphical desktop
Authentication SSH key recommended Password commonly used for RDP
OS licensing Depends on distribution Windows Server licensing applies
Web server Nginx / Apache IIS
Application workloads .NET, Java, Node.js, Python .NET, IIS, Windows services

ASP.NET Core applications can run on both Linux and Windows.

Choose Windows when the application requires Windows-specific dependencies, IIS features, or legacy .NET Framework components.

Choose Linux when the application is cross-platform and Windows-specific capabilities are unnecessary.


15. Azure VM Security Best Practices

Virtual machines must be secured before hosting production applications.

Recommended Practices

  1. Restrict management ports: Avoid allowing SSH or RDP from the entire internet.

  2. Use Azure Bastion: Access VMs without assigning public IP addresses directly to them.

  3. Use SSH keys: Prefer key-based Linux authentication.

  4. Enable backups: Protect application and system data using appropriate backup policies.

  5. Keep systems updated: Apply guest OS and application security updates.

  6. Use Managed Identity: Avoid storing Azure service credentials in application configuration.

  7. Enable monitoring: Use Azure Monitor and diagnostic capabilities.

  8. Apply least privilege: Grant only the Azure RBAC permissions required.

  9. Use disk encryption: Select appropriate encryption and key-management configurations.

  10. Separate environments: Organize development, testing, and production resources appropriately.


16. Azure VM Cost Optimization

Azure VM costs can be reduced by applying the following practices.

Practice Benefit
Choose the correct VM size Avoid overprovisioning
Enable auto-shutdown Reduce unnecessary compute usage
Deallocate unused VMs Stop compute billing
Use Reserved Instances Reduce eligible long-term compute costs
Use Spot VMs Reduce interruptible workload costs
Review managed disks Remove unnecessary storage
Review public IP resources Avoid unused IP charges
Configure budgets and alerts Detect unexpected spending
Use Azure Advisor Identify optimization opportunities

Example: Development VM

A development VM is required only during office hours.

Instead of running continuously:

              Development VM
                     |
               Start: 9 AM
                     |
                     v
               Development
                     |
                     v
             Stop: 6 PM
                     |
                     v
               Deallocated
                     |
                     v
             No Compute Billing
             Until Next Start

Auto-shutdown can stop the VM automatically. Starting it again generally requires a separate manual or automated action.


17. Delete Azure VM Resources After Practice

Deleting the VM alone may leave other resources behind.

Examples:

  • Managed disks

  • Public IP addresses

  • Network interfaces

  • Network Security Groups

  • Virtual Networks

For an isolated learning environment, deleting the dedicated resource group is often the simplest cleanup method.

Cleanup Steps

  1. Open Resource groups.

  2. Select vm-demo-rg.

  3. Review all contained resources.

  4. Click Delete resource group.

  5. Confirm the resource group name.

  6. Complete the deletion.

Warning: Resource group deletion is destructive and can remove every resource in that group, including resources created by other people. Review its contents carefully before proceeding.

Deletion is asynchronous and can take several minutes. Verify that resources have been removed and check for related resources or charges outside the group.


18. Real-Time Scenario: Hosting an ASP.NET Core Web API on Azure VM

Consider an ASP.NET Core Web API application with SQL Server.

One possible VM-based architecture is:

                    Internet
                        |
                        v
                  HTTPS Request
                        |
                        v
                Azure Public IP
                        |
                        v
                 NSG / Firewall
                        |
                        v
               Azure Windows VM
                        |
                 IIS Web Server
                        |
                        v
                 ASP.NET Core
                    Web API
                        |
                        v
                 SQL Server
                  Database

For a small demonstration, IIS and the API may run on one Windows VM.

For production, prefer a secure architecture with private database connectivity, TLS termination, restricted network access, backup policies, and appropriate redundancy.

Depending on the application's requirements, Azure App Service and Azure SQL Database may reduce operational overhead compared with self-managed VMs.

Key Points

  • Azure VMs support hosting ASP.NET Core applications.

  • IIS can host ASP.NET Core applications on Windows Server.

  • Linux VMs can host ASP.NET Core with Nginx or another reverse proxy.

  • NSGs control network access.

  • Production systems require monitoring, backups, and high availability.


19. Important Azure Virtual Machine Interview Questions and Answers

The following questions focus specifically on Azure Virtual Machines, their pricing, networking, storage, security, and administration.

Group 1: Azure VM Fundamentals

Q1. What is an Azure Virtual Machine?

An Azure VM is an IaaS service that provides virtualized computing resources such as CPU, RAM, storage, and networking. It supports Windows and Linux operating systems.

Q2. What is the difference between an Azure VM and Azure App Service?

Azure VM provides operating system-level control, while Azure App Service is a managed PaaS hosting service. VMs require more infrastructure administration.

Q3. What is the difference between IaaS and PaaS?

IaaS provides virtual infrastructure that customers manage at the OS level. PaaS manages more infrastructure and runtime responsibilities, allowing developers to focus on applications.

Q4. What is a hypervisor?

A hypervisor is a virtualization layer that allows multiple isolated virtual machines to run on shared physical hardware.

Group 2: VM Sizes and Pricing

Q5. What are the main Azure VM series?

B-Series is burstable, D-Series is general purpose, E-Series is memory optimized, F-Series is compute optimized, and N-Series supports GPU workloads.

Q6. What is the difference between B-Series and D-Series VMs?

B-Series uses CPU credits for burstable workloads. D-Series provides general-purpose compute resources suitable for more consistent application workloads.

Q7. What are Azure Spot VMs?

Spot VMs use unused Azure capacity at discounted rates. They can be evicted, so they are suitable for fault-tolerant and interruptible workloads.

Q8. What is an Azure Reserved VM Instance?

It is a billing commitment for eligible VM compute usage over one or three years, providing discounts compared with standard pay-as-you-go pricing.

Q9. How do you reduce Azure VM costs?

Right-size VMs, deallocate unused instances, enable auto-shutdown, remove unused disks, use eligible reservations, and monitor costs with Azure Cost Management.

Group 3: Azure VM Storage

Q10. What is the difference between an OS disk and a data disk?

The OS disk contains the operating system. Data disks provide additional persistent storage for application files, databases, and logs.

Q11. What is a temporary disk in Azure VM?

A temporary disk provides local, nonpersistent storage on supported VM sizes. Its contents may be lost during maintenance or deallocation.

Q12. What are Azure Managed Disks?

Managed Disks are Azure-managed block storage resources for virtual machines. Azure handles the underlying storage infrastructure.

Q13. What is the difference between Standard SSD and Premium SSD?

Standard SSD is suitable for moderate-performance workloads, while Premium SSD provides higher performance for demanding production applications.

Q14. Can a data disk exist after deleting a VM?

Yes. A managed data disk can be retained if the VM's disk deletion setting is configured to detach rather than delete it.

Group 4: Azure VM Networking

Q15. What is the difference between a public IP and a private IP?

A public IP supports internet connectivity. A private IP supports communication inside Azure VNets and connected private networks.

Q16. What is an Azure Network Security Group?

An NSG is a stateful network traffic filter that allows or denies inbound and outbound traffic using security rules.

Q17. What happens when two NSG rules match the same traffic?

The rule with the lower numerical priority is evaluated first and determines the action within that NSG.

Q18. Can an NSG be attached to both a subnet and a NIC?

Yes. Traffic must satisfy applicable rules at both levels.

Q19. What is the difference between SSH and RDP?

SSH provides encrypted command-line remote access, typically on port 22. RDP provides graphical remote desktop access, typically on port 3389.

Group 5: VM Lifecycle and Management

Q20. What is the difference between Stopped and Stopped (deallocated)?

A stopped but allocated VM can continue incurring compute charges. A deallocated VM releases its compute allocation and stops normal VM compute billing.

Q21. Does Azure charge for disks when a VM is deallocated?

Yes. Managed disks remain allocated and can continue generating storage charges.

Q22. What is Azure VM auto-shutdown?

Auto-shutdown is a scheduling feature that can automatically stop and deallocate supported VMs at a configured time.

Q23. What is Azure VM boot diagnostics?

Boot diagnostics provides console screenshots and serial log information to help troubleshoot VM startup problems.

Q24. Can you resize an Azure VM?

Yes. Azure supports changing VM sizes, subject to available capacity, hardware compatibility, disk capabilities, and potential downtime.

Group 6: Real-Time Scenario-Based Questions

Q25. Your Azure VM is stopped, but you are still being charged. Why?

The VM may be stopped but still allocated. Verify that its status is Stopped (deallocated). Disk and other associated resource charges can continue.

Q26. You cannot connect to a Linux VM using SSH. What will you check?

Check VM status, IP address, NSG rules for TCP 22, routing, SSH service status, username, and private key permissions.

Q27. You cannot connect to a Windows VM using RDP. What will you check?

Check VM status, network connectivity, NSG rules for TCP 3389, Windows Firewall, RDP configuration, and login credentials.

Q28. A production VM requires additional storage. What will you do?

Attach or expand a supported managed data disk, then configure partitions, filesystems, and mounts inside the operating system as required.

Q29. Your application requires a VM with high memory. Which series would you choose?

Consider E-Series for memory-intensive workloads, then select a size based on actual RAM, CPU, and performance requirements.

Q30. A batch-processing application can tolerate interruptions. Which VM pricing model would you choose?

Azure Spot VMs are suitable because they provide discounted compute capacity for workloads designed to tolerate eviction.


20. Key Takeaways

Concept Important Point
Azure Virtual Machine IaaS service providing virtualized computing
B-Series Burstable workloads
D-Series General-purpose workloads
E-Series Memory-intensive workloads
Pay-as-you-go Flexible usage without commitment
Reserved Instances Discounts for eligible committed compute usage
Spot VMs Discounted but interruptible compute
OS Disk Stores the operating system
Data Disk Stores persistent application data
Temporary Disk Nonpersistent local storage on supported sizes
Managed Disks Azure-managed block storage
Public IP Supports internet connectivity
Private IP Supports private network communication
NSG Controls inbound and outbound traffic
SSH Linux remote access, typically port 22
RDP Windows graphical remote access, typically port 3389
Stopped (allocated) Compute charges may continue
Stopped (deallocated) Normal VM compute charges stop
Auto-shutdown Helps reduce unnecessary compute costs
Boot diagnostics Helps troubleshoot VM startup
Azure Bastion Secure remote access without directly exposing VM public IPs

Conclusion

Azure Virtual Machines provide flexible infrastructure for running Windows and Linux workloads in Microsoft Azure.

Understanding VM sizing, pricing models, managed disks, networking, NSGs, and VM lifecycle management is essential for developers, cloud administrators, and Azure engineers.

In this tutorial, we covered both conceptual fundamentals and practical implementation, including creating Ubuntu and Windows Server VMs, connecting through SSH and RDP, configuring storage, and managing VM costs.

The most important operational lesson is to understand the difference between Stopped and Stopped (deallocated), because this directly affects Azure compute billing.

For production environments, combine proper VM sizing with secure networking, monitoring, backups, and appropriate availability configurations.

What's Next?

Azure Virtual Machines – Advanced Concepts

In the next article, we will explore:

  • Availability Sets

  • Availability Zones

  • Virtual Machine Scale Sets

  • Azure VM Backup

  • Azure Bastion

  • VM Extensions

  • High availability and scaling strategies

These concepts build on the fundamentals covered here and are particularly useful for AZ-104 preparation and real-world Azure administration.

Tags: Azure Virtual Machines, Azure VM Sizes, Azure VM Pricing, Azure Managed Disks, Azure Networking, Azure NSG, Azure Linux VM, Azure Windows VM, SSH, RDP, Azure Fundamentals, AZ-104

 

← Back to Articles