Azure Virtual Machines (VMs)

What is Azure Virtual Machines?

Azure Virtual Machines (VMs) are scalable, on-demand computing resources in Microsoft Azure. They allow you to run applications, host services, and perform cloud-based workloads just like a physical server.

Why Use Azure Virtual Machines?

  • Scalability: Easily scale up or down based on demand.
  • Flexibility: Supports Windows, Linux, and custom machine images.
  • Cost-Efficient: Pay only for what you use.
  • Security: Integrated with Azure security services.

Types of Azure VMs

Azure provides different VM types optimized for various workloads:

  • General Purpose: Balanced CPU-to-memory ratio (e.g., B-series, D-series).
  • Compute Optimized: High CPU performance (e.g., F-series).
  • Memory Optimized: High RAM for databases (e.g., E-series).
  • Storage Optimized: Optimized for disk throughput (e.g., L-series).
  • GPU & HPC: For AI, ML, and deep learning workloads.

How to Create an Azure VM (Step-by-Step)

Step 1: Login to Azure Portal

Go to Azure Portal and sign in with your account.

Step 2: Create a Virtual Machine

Click on "Create a resource" → Select "Virtual Machine".

Step 3: Configure Basic Settings

  • Subscription: Choose your Azure subscription.
  • Resource Group: Create or select an existing group.
  • VM Name: Enter a unique name for your VM.
  • Region: Choose the closest Azure data center.
  • Image: Select the OS (Windows/Linux).

Step 4: Select VM Size

Choose a VM size based on your workload (B1s, D2s, etc.).

Step 5: Set Up Authentication

You can choose:

  • **SSH Key** (Recommended for Linux VMs).
  • **Password Authentication** (For Windows or basic Linux access).

Step 6: Configure Networking

Ensure your VM has a **public IP** and is part of a **Virtual Network (VNet)**.

Step 7: Review and Deploy

Click "Review + Create" and wait for deployment.

How to Connect to an Azure VM

For Windows VM (RDP)

Use Remote Desktop to connect:

mstsc /v:

For Linux VM (SSH)

Connect using SSH:

ssh azureuser@

Managing Azure VMs Using CLI

Create a VM Using Azure CLI

az vm create --resource-group MyResourceGroup --name MyVM --image UbuntuLTS --admin-username azureuser --generate-ssh-keys

Start a VM

az vm start --name MyVM --resource-group MyResourceGroup

Stop a VM

az vm stop --name MyVM --resource-group MyResourceGroup

Delete a VM

az vm delete --name MyVM --resource-group MyResourceGroup --yes

Cost Optimization Tips

  • Use **Spot VMs** for cost savings.
  • **Auto-shutdown** for development/test environments.
  • Monitor with **Azure Cost Management**.

Conclusion

Azure Virtual Machines provide powerful, scalable, and flexible cloud-based computing. Whether for hosting applications, databases, or large-scale workloads, VMs offer a reliable solution.

📌 Next Topic: Azure App Service - Deploying Web Applications