DEV Community

Cover image for How to Deploy and Connect to an Azure VMSS
JICDev
JICDev

Posted on

How to Deploy and Connect to an Azure VMSS

What is Azure VMSS?

Azure Virtual Machine Scale Set (VMSS) is a Microsoft Azure service that lets you deploy and manage a group of identical virtual machines (VMs) — automatically.

Think of it like:

“A smart cluster of servers that can grow or shrink depending on workload.”

It’s designed for:

  • Auto-scaling: Automatically adds/removes VMs based on demand.
  • Load balancing: Distributes traffic evenly across VMs.
  • High availability: If one VM fails, others keep running.
  • Easier management: All instances share the same configuration and can be updated together.

Real-World Example

Imagine your app runs fine on 2 VMs during the day, but at night or during traffic spikes, you need 10.

With VMSS, Azure can automatically scale up when CPU > 70% and scale down when traffic drops — no manual effort.


Core Components of a VMSS

Component Description
Instance Template Defines the base image, size, and configuration of each VM.
Scaling Policy Rules for how to increase or decrease the number of VMs.
Load Balancer Distributes incoming traffic across all VM instances.
Health Probe Monitors VMs and removes unhealthy ones from the load balancer.

Types of Scaling

  1. Manual scaling — You decide how many VMs to run.
  2. Automatic scaling — Azure scales based on rules (e.g., CPU usage, memory, request count).

Step-by-Step: How to Create a VMSS on Azure Portal

Step 1: Go to the Azure Portal

👉 https://portal.azure.com


🧰 Step 2: Search for "Virtual Machine Scale Sets"

  • In the search bar at the top, type Virtual Machine Scale Sets
  • Click Create

⚙️ Step 3: Basics Tab

Fill out the required info:

Field Example Value
Subscription Your active Azure subscription
Resource Group Create new → vmss-demo-rg
Virtual machine scale set name myVMSS
Region Choose closest to you (e.g., East US, West Europe)
Orchestration mode Uniform (default)
Image Ubuntu Server 22.04 LTS
VM Size Standard_B1s (cheap & small for demo) NB: Depending on the region, The size might not activate, therefore you might need to adjust select the appropriate zones

Then under Authentication type, select Password or SSH public key.
Under “Scaling policy”:

  • Choose Custom autoscale
  • Example rules:

    • Scale out when CPU > 70% for 10 mins
    • Scale in when CPU < 30% for 10 mins
    • Minimum: 1 instance
    • Maximum: 3 instances

NB: I am using 2

🌐 Step 4: Networking

  • Leave Create new virtual network selected.
  • Load balancing: select Azure Load Balancer (default).
  • Health probe: leave automatic.

Create a Load Balancer

Click on create new if you have none and then give it a name. the rest of the data should be left on default.


💾 Step 6: Review + Create

  • Click Review + Create
  • Wait for validation → Click Create

If everything checks out you should have your VM successfully deployed

Azure will deploy your VMSS — takes about 5–7 minutes.


🚀 Step 7: Access Your VMSS

Once it’s ready:

  1. Go to the VMSS Overview Page
  2. Click Instances to view all running VMs
  3. Open the Load Balancer public IP in your browser — it connects to your VMSS backend.

If you set up a load balancer, you can access the VMSS via its frontend public IP.


🧪 Step 8: Test Scaling

You can:

  • Manually increase instance count in the Scaling tab
  • Or simulate load using:
  sudo apt install stress
  stress --cpu 2 --timeout 120
Enter fullscreen mode Exit fullscreen mode

Step 7: Verify and Access Your VMSS

Once deployment completes:

  1. Go to the VMSS Overview Page
  2. Click Instances to view all running VMs
  3. Open the Load Balancer public IP in your browser — it connects to your VMSS backend.

Step 8: Simulate Load and Test Autoscaling

SSH into your instance and run:

sudo apt update && sudo apt install stress -y
stress --cpu 2 --timeout 120
Enter fullscreen mode Exit fullscreen mode

After a few minutes, Azure will detect high CPU usage and automatically scale up your VM count.


Summary

Feature Benefit
Auto-scaling Adjusts to traffic automatically
Load balancing Ensures even distribution of requests
High availability Handles failures gracefully
Cost-efficient Only pay for what you use

Final Thoughts

With Azure VMSS, you don’t have to manually add or remove servers.
It scales intelligently, maintains uptime, and saves cost — all while being beginner-friendly to set up.

#Azure #DevOps #Cloud #Scaling #VMSS

Top comments (0)