Azure Virtual Machine Scale Sets Deep Dive: Orchestration, Autoscale, Resilience and Operations
A book-style guide to how Virtual Machine Scale Sets really work, from orchestration modes and images to autoscale, availability zones, health repair, networking, Spot capacity and cost control.
Imagine a taxi company. On a quiet Tuesday morning it needs five cars on the road. On a rainy Friday evening it needs fifty. A sensible company does not buy fifty cars and leave forty-five parked all week, and it does not hire a mechanic to prepare each new car by hand every time demand jumps. Instead it keeps one carefully prepared template of a car, has a dispatcher who watches demand, and brings cars onto the road or sends them home automatically, spreading them across different garages so one flooded garage never stops the whole fleet. Virtual Machine Scale Sets are that taxi company for your servers.
This guide goes far beyond the first deployment. We will open the engine: the two orchestration modes and why one is recommended, how an instance is born and becomes useful, how autoscale decides, how fault domains and zones protect you, how health repair and updates work, how networking differs between modes, and which mistakes quietly damage production fleets. Every new term is explained when it first appears, and every major idea comes with an everyday comparison.
1What Virtual Machine Scale Sets Really Are
A scale set lets you create, manage and scale a group of virtual machines as one unit instead of as many separate servers.
The Simple Definition
A virtual machine is a software-defined computer running in Azure. Running one is simple. Running fifty identical ones is a headache: you must create each, keep their settings the same, spread them across failure boundaries, add more when traffic rises and remove them when it falls. A Virtual Machine Scale Set, often shortened to VMSS, solves this by letting you describe the machine once and then ask Azure for any number of copies. The group can grow and shrink automatically in response to load or a schedule, and Azure helps spread the copies across separate hardware so that a single failure does not take everything down.
It exists because many workloads need the control of full virtual machines, such as custom software, special operating system settings, unusual drivers or licensed products, but still want cloud elasticity. It is used for web tiers behind load balancers, batch and compute grids, game servers, build agents, back-end services and the node pools of container platforms.
A single virtual machine is a lone food truck. A scale set is a franchise: one recipe book and one truck design, copied as many times as the lunch rush demands, each truck parked in a different part of the city, and closed down again when the crowd leaves.
What You Manage and What Azure Manages
Azure manages the physical hardware, the hypervisor, the placement of instances and the automation that creates and deletes them. You manage everything inside each virtual machine: the operating system configuration, patching, installed software, security settings, application deployment and monitoring. This is Infrastructure as a Service, so you have maximum control and maximum responsibility. A scale set removes the repetitive work of managing many machines but does not remove the work of managing the machine itself.
| Concern | Single Virtual Machines | Scale Set | App Service or Functions |
|---|---|---|---|
| Operating system patching | You | You | Microsoft |
| Adding capacity | You, by hand | Automatic or one setting | Automatic or one setting |
| Consistency across copies | You, with effort | Built in through one model | Built in |
| Control over the machine | Full | Full | Limited |
| Best for | Pets with unique needs | Fleets of similar machines | Standard web or event workloads |
The scale set itself has no separate charge. You pay for the virtual machines, disks, network and other resources it creates. That means the cost lever is how many instances run and for how long, not the scale set feature.
Pets and Cattle
A popular saying in operations separates pets from cattle. A pet server has a name, is hand-crafted and is nursed back to health when it is sick. A cattle server is one of many identical machines, numbered not named, and replaced rather than repaired. Scale sets are built for cattle. The healthiest designs treat every instance as disposable and keep important data outside it.
2Core Concepts and Vocabulary
Twelve terms appear in almost every conversation about scale sets. Learn them once and the rest falls into place.
Scale Set Model
The blueprint that describes every instance: size, image, disks, network, extensions and settings. Changing the model changes what future instances look like.
Instance
One virtual machine created from the model. Instances are meant to be interchangeable.
Orchestration Mode
The management style of the scale set, either Flexible or Uniform. It is chosen at creation and cannot be changed later.
Fault Domain
A group of machines sharing power and network equipment, so they can fail together. Spreading instances across fault domains limits the damage of one failure.
Availability Zone
A physically separate datacenter within a region, with independent power, cooling and networking.
Image
The disk template an instance boots from. It can be a marketplace image or your own, shared through an Azure Compute Gallery.
Extension
A small add-on that runs inside an instance after it is created, for tasks like configuration, monitoring or health reporting.
Autoscale Profile
The set of rules and schedules that decide how many instances should run, with a minimum, maximum and default.
Application Health Extension
A probe installed in each instance that reports whether the application is truly healthy, used for repairs and safe updates.
Scale-in Policy
The rule that decides which instances are removed first when the set shrinks.
Spot Instance
Spare Azure capacity offered at a large discount, which Azure can take back when it needs the room.
Placement Group
An internal grouping of instances used by one orchestration mode to manage large sets. It matters mainly for older designs.
The Model and the Instances Can Drift
The model is the intention, and each instance is the reality. When you change the model, existing instances do not necessarily change at once. Depending on your upgrade approach, they may stay on the old version until you update, refresh or replace them. This gap is called model drift, and it is a common source of confusion: a fleet that looks uniform in the portal can contain machines built from three different versions of the blueprint.
The model is the master blueprint pinned on the wall. Instances are houses already built. If you redraw the blueprint, houses built earlier keep the old design until someone renovates or rebuilds them. New houses use the new plan.
Fault Domains Versus Zones
Both protect against failure but at different scales. A fault domain protects against a rack or equipment failure inside one datacenter. An availability zone protects against the loss of a whole datacenter. A resilient design usually spreads across zones, and Azure then spreads further across fault domains within each zone where the mode and settings allow it.
Many people believe that having many instances automatically means high availability. If all instances share the same zone and the same fault domain, one failure can still remove all of them. Spreading, not just counting, is what creates resilience.
3Architecture and Components
A scale set is a control layer sitting on top of ordinary virtual machines and ordinary network resources.
The Big Picture
At the top is the Azure Resource Manager, the control plane that accepts your requests. Below it the scale set resource holds the model and the capacity setting. The platform’s compute fabric creates virtual machines on physical hosts according to that model. Each instance receives a network interface in your virtual network subnet and attaches managed disks. In front of the instances there is typically a load balancer or an application gateway that spreads incoming traffic. Beside them sit monitoring services and autoscale, which watch metrics and change the capacity.
flowchart TD
USER["Operator or Pipeline"] --> ARM["Azure Resource Manager"]
ARM --> VMSS["Scale Set Model and Capacity"]
AUTO["Autoscale Engine"] -->|"changes capacity"| VMSS
MON["Azure Monitor Metrics"] --> AUTO
VMSS --> FAB["Compute Fabric"]
FAB --> I1["Instance in Zone 1"]
FAB --> I2["Instance in Zone 2"]
FAB --> I3["Instance in Zone 3"]
I1 --> NIC["Network Interfaces in Subnet"]
I2 --> NIC
I3 --> NIC
LB["Load Balancer or Application Gateway"] --> NIC
I1 --> DSK["Managed Disks"]
I2 --> DSK
I3 --> DSK
I1 -.-> MON
I2 -.-> MON
I3 -.-> MON
The Control Plane and the Data Plane
The control plane is how you manage resources: creating the set, changing capacity or updating the model. The data plane is how users reach your application through the load balancer and into the instances. They fail independently. A problem with the management service does not stop traffic already flowing, and a traffic flood does not stop you from changing capacity, although a flood may make you wish you had done so sooner.
The Resources Around the Set
Virtual Network and Subnet
Every instance gets an address from a subnet. Subnet size limits how large the set can ever grow.
Load Balancer
Spreads traffic and checks instance health. A Standard load balancer is the usual partner in modern designs.
Managed Disks
The operating system disk and any data disks, managed by Azure. Some instances use local ephemeral disks for speed.
Compute Gallery
A versioned library of your custom images that can be replicated to regions and shared across teams.
Managed Identity
Lets instances call Azure services such as Key Vault or storage without stored passwords.
Monitoring Agent and Metrics
Collect host and guest metrics and logs so autoscale and operators can see what is happening.
Plan the subnet before the scale set. A subnet that is too small blocks scale-out with confusing errors, and enlarging a busy subnet later is far harder than choosing a generous size at the start.
4Internal Working: The Life of a Scale-Out Event
Following one scale-out from trigger to first customer request shows why scaling takes minutes, not seconds.
sequenceDiagram
participant M as Metrics
participant A as Autoscale
participant R as Resource Manager
participant F as Compute Fabric
participant V as New Instance
participant H as Health Probe
participant L as Load Balancer
M->>A: CPU stays above threshold
A->>A: Evaluate rules and cooldown
A->>R: Raise capacity by one
R->>F: Create instance from model
F->>V: Allocate host and boot image
V->>V: Run extensions and start app
H->>V: Probe application
V-->>H: Healthy
H->>L: Add instance to rotation
L->>V: First customer request
A Metric Crosses a Line
Autoscale watches a metric such as average CPU across instances. When the metric stays beyond a threshold for a set time window, a rule fires.
The Decision
Autoscale checks cooldown, minimum and maximum limits, and the current instance count, then chooses a new capacity and sends the request.
Placement and Allocation
The compute fabric finds hardware with room, respecting zones and fault domains. If capacity of that size is short in the chosen zone, allocation can fail.
Boot and Configure
The instance boots from the image, receives its network interface, attaches disks and runs extensions and startup scripts. Heavy installation here makes everything slower.
Health Confirmation
A probe checks whether the application answers properly. Until it does, the instance should not receive traffic.
Traffic Joins
The load balancer adds the instance, and customers finally benefit from the extra capacity.
Why Scale-Out Is Slow Compared With Platforms Like Functions
Adding a whole virtual machine means allocating hardware, copying or attaching a disk, booting an operating system, running configuration and starting your application. Even when each step is fast, the total commonly takes minutes. That is perfectly fine for gradual growth, but it cannot rescue you from a spike that arrives in ten seconds. The answer is to scale early, keep headroom, schedule capacity ahead of known events and absorb bursts with queues and caches.
Scaling out virtual machines is like calling in extra waiters from home. They need time to travel, put on uniforms and learn the specials. If the restaurant fills up in a moment, customers wait. Smart managers call extra staff before the party arrives, not after the queue forms.
Boot Time Is a Design Choice
You control most of the boot time. An instance that boots from a fully prepared custom image, with the application already installed, can be ready in a short time. An instance that boots from a plain image and then downloads packages, compiles code and configures itself at startup can take far longer, and is more likely to fail if a download site is slow or unavailable. This is why mature teams build images in advance rather than installing at boot.
Installing software from the public internet during every instance boot. When the download site is slow or down, scale-out silently produces broken instances at the very moment you need capacity most. Bake dependencies into the image.
5Orchestration Modes: Flexible and Uniform
The single most important choice you make when creating a scale set is its orchestration mode, because it cannot be changed afterward.
Two Styles of Management
Uniform orchestration is the original style. The scale set owns identical instances created from one model, and you manage them through scale set operations. Flexible orchestration is the newer style. It gives you the benefits of scale sets, scale and spread, while letting you work with each instance much like an ordinary virtual machine, and even mix different kinds of machines. Microsoft describes Flexible orchestration as the recommended mode for new scale sets, and has also moved the default mode of command-line and scripting creation tools from Uniform to Flexible.
| Area | Flexible | Uniform |
|---|---|---|
| Recommendation | Recommended for new deployments | Older style, still supported |
| Instance count | Up to 1,000 virtual machines with fault domain guarantees | Larger counts are possible with multiple placement groups, and documentation figures vary, so check the current limits page |
| Fault domains | Regional sets can use up to three where the region allows, and one with max spreading across zones | Two, three or five depending on configuration |
| Zones | One, two or three, and instances can be pinned to a zone | One, two or three, with no pinning |
| Mixing machine types | Mixed operating systems, mixed Spot and on-demand, and mixed sizes with max spreading | Same operating system, and Spot or regular but not both |
| Default outbound internet access | None, you must provide explicit outbound connectivity | Provided by default |
| Load balancer | Standard load balancer, with NAT rules but no NAT pools | Basic and Standard load balancers, NAT pools supported |
| Automatic OS image upgrades | Not supported, use in-guest patching | Supported |
| Managed identity | User-assigned | System-assigned or user-assigned |
| Backup and Site Recovery | Supported | Not supported |
| Container and cluster platforms | Not supported for AKS and Service Fabric | Supported |
| Availability SLA | 99.95 percent across fault domains, 99.99 percent across multiple zones | Same targets under matching conditions |
Uniform is a fleet of identical rental cars managed from one central dashboard: simple and strict. Flexible is a managed fleet where you may also include a van, a truck and a bargain borrowed car, each still tracked and spread across garages by the same dispatcher.
Migration Is a Rebuild, Not a Switch
Because the mode is fixed at creation, there is no automatic upgrade from Uniform to Flexible and no automated tool to move machines from an availability set. Microsoft recommends a blue-green approach: create a new Flexible scale set beside the old one, send traffic to it gradually, and then shrink or remove the old one. Several template details change too, such as removing NAT pools and overprovisioning settings, and making the fault domain count explicit. Treat the move as a project with testing and a rollback plan.
flowchart LR
OLD["Existing Uniform Scale Set"] --> LB["Shared Load Balancer or Gateway"]
NEW["New Flexible Scale Set"] --> LB
LB --> USERS["Users"]
TEST["Validate new set"] --> NEW
SHIFT["Shift traffic in steps"] --> LB
OLD -.-> RET["Scale down and retire after stable period"]
Instances created automatically by autoscale in a Flexible set do not receive default outbound internet access. If your instances download updates or call external APIs, provide outbound connectivity explicitly with a NAT gateway, a firewall route, a Standard load balancer outbound rule or a public address.
Advantages of Flexible
- Recommended and receiving the most investment
- Mix machine sizes, operating systems and Spot with on-demand
- Pin instances to zones or fault domains when needed
- Instances behave like standard virtual machines
- Backup and Site Recovery are supported
Trade-offs of Flexible
- No default outbound access, so networking needs explicit design
- No automatic OS image upgrades
- No support for some platforms such as AKS node pools
- Some Uniform features such as instance protection differ
- Existing Uniform sets must be rebuilt, not converted
A Simple Decision Guide
Does a Platform Require Uniform?
If you are running AKS node pools or Service Fabric clusters, those platforms use Uniform scale sets today. Follow the platform’s own guidance.
Do You Need Mixed Machines or Spot Plus On-demand?
If you want different sizes, mixed operating systems or a blend of Spot and regular instances in one set, choose Flexible.
Do You Rely on Automatic OS Image Upgrades?
If this feature is a must-have today, note that Flexible does not offer it. Plan an image refresh pipeline, or weigh whether Uniform suits you.
Is This a New Deployment?
For new work with none of the special requirements above, choose Flexible. It is the recommended path and the default of the command-line tools.
6Images, Configuration and Instance Lifecycle
What an instance looks like when it first wakes up decides how fast, how reliably and how consistently your fleet scales.
Three Ways to Prepare an Instance
Plain Image Plus Startup Script
Boot a marketplace image and install everything at startup. Simple to begin with, slow to scale, and fragile when downloads fail.
Custom Golden Image
Prepare an image with the operating system settings and application already installed. Fast, consistent and the usual choice for production.
Image Plus Light Configuration
Use a golden image for slow-changing parts, then apply small, quick settings at boot such as environment names and secrets retrieval.
Container Host Image
Keep the image minimal and run the application as a container pulled from a registry, separating machine and application lifecycles.
A plain image with a startup script is like hiring a chef who arrives with an empty bag and must shop, chop and cook from scratch for each order. A golden image is a chef who arrives with ingredients prepped and the oven already hot.
Azure Compute Gallery and Image Versions
An Azure Compute Gallery stores your custom images as numbered versions. A scale set can point at a specific version or at the latest one. You can replicate versions to several regions so that scale-out in each region is fast and local, and share them across subscriptions and teams. Pinning a specific version makes deployments predictable, while using the latest version keeps fleets current but can surprise you with an untested change. Most teams pin versions in production and promote them through test environments first.
Extensions and Configuration at Boot
Extensions run inside the instance to perform tasks like installing monitoring agents, running configuration scripts or reporting health. Keep them few and fast. Each extension adds boot time, and a failing extension can leave an instance half-ready. Order matters when extensions depend on each other. Store secrets in a vault and fetch them with a managed identity instead of embedding them in scripts or settings that anyone with read access can see.
Disks: Persistent, Data and Ephemeral
The operating system disk can be a regular managed disk, which survives deallocation, or an ephemeral disk placed on local storage of the host. Ephemeral disks are fast, cost nothing extra for storage and are quick to reset, which suits stateless instances, but their contents vanish if the instance is moved or reimaged. Data disks attached to instances give persistent storage, but a scale set is not designed for individually precious disks. Anything truly important belongs in a database, a storage account or a file service outside the instances.
| Storage Choice | Survives Instance Deletion | Speed | Good For |
|---|---|---|---|
| Managed OS disk | No, deleted with the instance by default | Standard to fast depending on type | General instances |
| Ephemeral OS disk | No | Very fast, local | Stateless, quick-reset instances |
| Attached data disk | Depends on settings | Depends on disk type | Scratch data and caches |
| External database or storage | Yes | Network-bound | Anything that must last |
Keeping user uploads or application logs only on the instance disk. When autoscale removes that instance, the data disappears with it. Ship logs to a central place continuously and write uploads to shared storage.
Problem
Engineers log in to individual instances and fix them by hand, installing packages or editing files directly.
Why It’s Harmful
The instance now differs from the model. It will vanish at the next scale-in, reimage or upgrade, taking the fix with it, and new instances will still have the bug.
Correct Approach
Make every fix in the image or in the scripted configuration, publish a new version and roll it out. Treat manual changes as temporary experiments only.
Configuration Management Without Hand Work
Every instance should configure itself the same way without human help. Two common tools do this at boot: a cloud initialization script on Linux images and a custom script extension on both operating systems. Keep these scripts short, repeatable and safe to run twice. A script that fails halfway can leave an instance partly configured, so write it to check each step and exit with a clear error that the platform reports. Store the scripts in a controlled location with version history, and treat changes to them with the same review as application code.
Configuration that differs between environments, such as which database to talk to or which feature flags are on, should come from a central source at boot, such as an app configuration service or a vault, rather than being baked into images. This keeps one image usable in test and production, and changes the environment by changing settings rather than rebuilding.
Make boot scripts idempotent, meaning running them twice gives the same result as running once. Repairs, reimages and retries may run them again, and an unsafe script can turn a small blip into a fleet-wide problem.
7Autoscale Deep Dive
Autoscale is the engine of elasticity. It is simple to switch on and surprisingly easy to misconfigure.
How Autoscale Decides
Autoscale is a service of Azure Monitor. It attaches to a scale set and holds a profile with a minimum, a maximum and a default number of instances, plus rules. Metric-based rules look at measurements such as average CPU, memory, network, disk activity, queue length or custom application metrics. Schedule-based rules change capacity at set times, for example more instances during business hours. Predictive autoscale can also study the history of a CPU-based pattern and add capacity slightly ahead of the expected rise, which helps with the slow boot time of virtual machines.
| Style | Decides By | Strength | Weakness |
|---|---|---|---|
| Manual | You set a number | Predictable and simple | Does not react to change |
| Metric-based | Live measurements and thresholds | Reacts to real demand | Reacts after demand appears, and VMs boot slowly |
| Schedule-based | Clock and calendar | Perfect for known peaks and quiet periods | Blind to surprises |
| Predictive | Learned patterns of past load | Adds capacity before the rise | Needs history and regular patterns |
Anatomy of a Good Rule Pair
Every scale-out rule needs a matching scale-in rule, with enough distance between the two thresholds. Imagine scale-out at seventy percent CPU and scale-in at thirty percent. In between, nothing happens, which is exactly what you want. If both thresholds sit too close together, the set oscillates: it adds an instance, load per instance drops, the scale-in rule fires, load rises again and the cycle repeats. This is called flapping. Autoscale has built-in protection that estimates what the metric would be after a scale-in and skips the action if it would immediately trigger a scale-out, but good thresholds are still your first defense.
Thresholds are like a home thermostat. If it turns the heating on at twenty degrees and off at twenty-one, it clicks on and off all night. A wider gap lets the room settle. Autoscale rules need the same breathing room.
Windows of Time and Cooldown
A rule looks at a metric over a time window, such as the average across ten minutes. A short window reacts faster but is jumpy. A long window is steady but slow. After a scale action, a cooldown period pauses further changes so the new instance has time to boot and take load. Set the cooldown to at least as long as your typical time from creation to useful traffic. Otherwise autoscale keeps adding instances while earlier ones are still starting, and you overshoot.
Choosing What to Measure
CPU Percentage
Simple and always available from the host. Works well for compute-bound services but misses problems caused by waiting on dependencies.
Memory
Needs a guest agent to report it. Important for memory-hungry apps that never raise CPU much.
Queue Length
A backlog is the clearest sign that workers are too few. Ideal for worker fleets that pull jobs.
Request Rate or Latency
Closest to user experience. Often taken from a gateway or from application telemetry.
Scale-in Policy: Who Leaves First
When the set shrinks, a scale-in policy chooses which instances to remove. The default behavior balances instances across zones and fault domains first, so that shrinking does not leave one zone empty, and then removes within the chosen group. Other policies remove the newest or the oldest instances first. Removing the oldest can help retire stale instances that drifted from the model, while removing the newest can protect warmed-up caches. Combine your choice with graceful shutdown so in-flight work finishes, and use termination notifications so instances can drain connections before they disappear.
Set a sensible minimum of at least two instances across two zones for production services, and a maximum that your downstream database, licenses and subnet can handle. The maximum is your seat belt against runaway cost.
Problem
Autoscale uses CPU alone, with a short window, a short cooldown and thresholds only ten points apart.
Why It’s Harmful
The set flaps, repeatedly creating and destroying machines, while real bottlenecks such as slow databases are invisible to CPU. Users see unstable performance and the bill grows.
Correct Approach
Use a metric tied to demand, add a wide gap between thresholds, match cooldown to boot time and add a schedule or predictive rule for known patterns.
A Worked Autoscale Example
Imagine a web fleet where one instance comfortably serves about a thousand requests per minute at sixty percent CPU, and a new instance takes six minutes to become healthy. A sensible design might set a minimum of three instances across three zones, a maximum of thirty, scale out by two instances when average CPU exceeds sixty-five percent over ten minutes, and scale in by one instance when average CPU stays below thirty-five percent over twenty minutes, with a cooldown of ten minutes after each action. Add a schedule that raises the minimum to six instances shortly before the weekday morning peak and lowers it in the evening. Predictive scaling, if the load pattern is regular, can add capacity slightly before the schedule would.
The logic behind the numbers matters more than the numbers. Scale out faster than you scale in, because being short of capacity hurts users while having extra capacity only costs a little. Make the cooldown longer than the boot time. Keep a gap between the thresholds. Cap the maximum at what the database and the subnet can support. Then test the whole design with a load test, because rules that look wise on paper often behave differently against a real application.
8Availability: Fault Domains, Zones and Capacity
Resilience comes from where instances sit, not just how many there are.
Spreading Choices
In a regional deployment without zones, instances can be spread across fault domains inside one datacenter. In a zonal deployment, instances are spread across availability zones, typically one, two or three of them. With maximum spreading, Azure places each instance in a separate fault domain as far as it can. Flexible orchestration lets you also pin an instance to a particular zone or fault domain when you need a specific layout, such as keeping a primary and a standby apart.
flowchart TD
LB["Zone-redundant Load Balancer"] --> Z1["Zone 1"]
LB --> Z2["Zone 2"]
LB --> Z3["Zone 3"]
Z1 --> A1["Instance A"]
Z1 --> A2["Instance B"]
Z2 --> B1["Instance C"]
Z2 --> B2["Instance D"]
Z3 --> C1["Instance E"]
Z3 --> C2["Instance F"]
A1 -.-> LOSS["If Zone 1 fails, four of six instances keep serving"]
What the Service Level Targets Mean
Azure states availability targets for scale sets depending on spread: about 99.95 percent when instances are spread across fault domains, and 99.99 percent when they are spread across multiple zones, under the documented conditions. These numbers describe the platform’s part of the story. Your real availability also depends on your application, your database, your load balancer configuration and your operational mistakes. A perfectly spread fleet running a buggy release is still down.
Spreading across zones is like storing copies of important documents in three different buildings. A fire in one building does not destroy them all. But if the document itself contains a mistake, every copy shares that mistake.
Capacity and Allocation Failures
Scale-out can fail when Azure does not have enough free machines of the requested size in the requested zone at that moment. This is called an allocation failure. It is rare for common sizes but more likely for scarce families, such as large GPU or high-memory machines, during regional shortages. You can reduce the risk by keeping your size choice flexible, using several sizes in one Flexible set with max spreading, spreading across zones, reserving capacity ahead of time with a capacity reservation for critical workloads, and by scaling earlier instead of at the last moment.
Capacity Reservation
Pay to hold a number of machines of a given size in a zone, guaranteeing they will be available when you need them. Suitable for critical, predictable events such as a product launch or a seasonal peak.
Size Diversification
Allow several comparable machine sizes in one set. If one size is short, another can fill the gap. Works best when your application behaves similarly on each size.
Early Scaling and Headroom
Keep a margin of spare capacity and start scaling before the fleet is hot. A fleet running at forty percent has time to react, while one at ninety percent does not.
Choosing one rare, large machine size in a single zone and assuming Azure can always supply more. A shortage of that exact size in that zone stops scale-out completely. Diversify sizes and zones, and test scale-out in advance.
9Health, Automatic Repairs and Updates
A fleet is only as good as its ability to notice sick machines and update healthy ones without hurting users.
Application Health Signals
Knowing that a virtual machine is powered on is not the same as knowing that your application works. The Application Health Extension runs inside each instance and reports whether the application answers a health check you define. In Flexible orchestration you install and configure it on each instance. Uniform instances can alternatively rely on a load balancer health probe. A good health endpoint checks the things that truly matter, such as the ability to reach the database and process a request, without becoming so deep that a small dependency hiccup marks the entire fleet unhealthy.
Automatic Instance Repairs
With repairs enabled, the platform watches the health signal. If an instance stays unhealthy beyond a grace period you configure, the platform replaces or restarts it according to your repair action. The grace period matters: it must be longer than normal boot and startup time, or healthy instances still starting up will be repaired in a loop. Repairs are not a substitute for fixing the cause. If instances keep failing, find out why instead of letting the fleet churn quietly.
Health Check Fails
The health endpoint stops answering correctly. The instance is marked unhealthy and removed from load balancer rotation.
Grace Period
The platform waits to see whether the problem is temporary, such as a slow startup or a brief dependency issue.
Repair Action
If the instance is still unhealthy, the platform performs the configured action, replacing, reimaging or restarting it.
Return to Service
The new instance boots, passes health checks and rejoins rotation.
Investigate
Alerts and logs record the event so a person can find the underlying cause rather than relying on endless repair.
Updating the Fleet
There are two things to update: the model, meaning the image and settings, and the operating system inside running instances. Uniform orchestration offers upgrade policies. Manual leaves instances alone until you apply the change. Automatic updates all at once, which is risky. Rolling updates in batches, checking health between batches, and pausing if too many instances become unhealthy. Uniform also supports automatic operating system image upgrades that follow new marketplace image releases. Flexible orchestration does not support automatic operating system image upgrades and relies on in-guest patching and on replacing instances or whole scale sets with a newer image. Documentation on upgrade features for Flexible is evolving, so check the current pages for the exact options you plan to use.
| Approach | How It Works | Risk | Best For |
|---|---|---|---|
| In-place patching | Patch tools update the running operating system | Instances drift from each other | Short-lived or stable fleets |
| Rolling image update | Replace instances in small batches with a new image version | Needs good health checks to stop bad releases | Production fleets that need consistency |
| Blue-green with a new scale set | Build a new set, move traffic, retire the old one | Temporary double cost | Large or risky changes and migrations |
| Manual reimage | You trigger updates on chosen instances | Human error and slow progress | Testing and small fleets |
Refresh your image on a regular schedule, for example monthly, instead of patching running machines forever. A fleet whose oldest instance is a few weeks old is easier to reason about than one with machines running unchanged for a year.
Instance Protection During Scale-in
Sometimes a particular instance is doing important work, such as finishing a long job, when autoscale decides to remove it. Uniform scale sets can mark instances as protected from scale-in. Flexible scale sets use other tools, such as resource locks, to prevent deletion. The best long-term answer is to design jobs so any instance can disappear, by checkpointing work and using queues that put unfinished jobs back.
Problem
Repairs are enabled with a very short grace period, and the health check is a simple ping that passes before the application finishes starting.
Why It’s Harmful
Instances are declared ready too soon and receive traffic that fails, or are repaired while still booting, creating a loop of replacement and instability.
Correct Approach
Make the health check reflect real readiness, set the grace period longer than the slowest normal startup, and alert on repeated repairs.
Batching and Pausing During a Rolling Update
A rolling update replaces instances in batches. You choose how many instances, or what percentage of the fleet, may be updated at once, and how many may be unhealthy before the roll pauses. A small batch is safer but slower, and a large batch is faster but risks reducing capacity below what traffic needs. A common approach is to start with about twenty percent per batch and a strict limit on unhealthy instances, then adjust based on how long your application takes to warm up. Add a pause between batches so health signals have time to appear. If a bad image causes failures, the roll stops after the first batch, leaving most of the fleet on the working version.
Remember that capacity dips during updates. If your fleet runs at seventy percent utilization and you take out twenty percent of instances for an update, the remainder runs hot. Schedule updates outside peak times, or add temporary surge instances so users do not feel the update.
10Networking Deep Dive
Networking is where Flexible and Uniform differ most, and where many first deployments go wrong.
Inbound Traffic
Most scale sets sit behind a load balancer or an application gateway. A Standard load balancer works at the network level, spreading connections by address and port, and can be zone-redundant. An application gateway works at the web level, understanding paths, host names and certificates, and can include a web application firewall. Both use health probes to avoid sending traffic to unhealthy instances. Individual instances normally have no public addresses at all. Administrators reach them through a bastion service, a private connection or a jump host instead of exposing remote login ports to the internet.
Standard Load Balancer
Fast, network-level distribution, with zone-redundant options and inbound NAT rules for controlled access to single instances.
Application Gateway
Web-aware routing, TLS handling and firewall protection in front of web fleets.
Bastion or Private Access
Secure remote management without public addresses or open management ports.
Network Security Groups
Allow and deny rules at the subnet or interface level, forming the basic firewall around the fleet.
Outbound Traffic and the Flexible Difference
Uniform scale sets receive default outbound internet access. Flexible scale sets do not, in line with Azure’s move toward explicit outbound design. If instances need to reach package repositories, partner APIs or Azure public services, you must provide a deliberate path: a NAT gateway attached to the subnet, a route through a firewall or network virtual appliance, outbound rules on a Standard load balancer, or a public address on each interface. A NAT gateway is the cleanest choice for most fleets, because it provides a stable outbound address that partners can allow and scales its connection capacity well.
flowchart TD
NET["Internet Users"] --> AG["Application Gateway with WAF"]
AG --> SUB["Scale Set Subnet"]
SUB --> INST["Instances without public addresses"]
INST --> NAT["NAT Gateway with fixed outbound address"]
NAT --> EXT["External APIs and update sources"]
INST --> PE["Private Endpoints"]
PE --> DB["Database and Storage with public access off"]
ADMIN["Administrator"] --> BAS["Bastion Service"]
BAS --> INST
Inbound is the front door of a shop, with a greeter and a security guard. Outbound is the staff delivery door at the back, where stock leaves and arrives. A new building code says every shop must now declare its back door explicitly instead of getting one for free.
Performance Features
Accelerated networking lets traffic bypass parts of the virtualization layer, lowering latency and CPU use for supported sizes. Proximity placement groups keep instances physically close for very low latency between them, which helps tightly coupled workloads but can reduce flexibility and increase the chance of allocation failure. Check that your chosen machine size and operating system support these features before building on them.
Subnet Sizing and Address Planning
Every instance consumes an address in its subnet, and Azure reserves a few addresses in every subnet. Size the subnet for your maximum instance count, plus room for rolling upgrades that temporarily run extra instances and for any parallel scale sets during migrations. Avoid address ranges that overlap with on-premises networks, because overlaps make future connections painful or impossible.
Moving to Flexible orchestration and discovering weeks later that new autoscaled instances cannot download updates or reach an external service. Explicit outbound connectivity must be part of the design, tested with an autoscale-created instance, not just a manually created one.
Health Probes at the Load Balancer
A load balancer sends test requests to each instance and removes any that fail from rotation. The probe is a separate thing from the platform health extension that drives repairs, and they can disagree. A probe that checks only that a port is open may pass while the application behind it is broken. A probe that calls a rich health endpoint may remove every instance at once if a shared dependency slows down. Design the endpoint so that it reflects the instance’s own readiness to serve traffic, with a light check of critical dependencies, and give it a sensible interval and failure threshold so brief hiccups do not remove healthy instances.
Also plan for connection draining. When an instance leaves rotation, existing connections should be allowed to finish for a short period, so users are not cut off mid-request. Combine this with the graceful shutdown behavior of your application for the smoothest scale-in and updates.
11Spot Capacity and Mixed Fleets
Spare capacity can cut compute cost dramatically, if your workload can tolerate being interrupted.
What Spot Instances Are
Azure always keeps some machines unused so it can serve sudden demand. Spot instances rent that spare capacity at a large discount, with one condition: Azure can take the machines back when it needs the room or when the market price exceeds your maximum. Spot instances come with no availability guarantee and are not covered by the usual availability targets. They are an excellent match for work that is flexible, interruptible and restartable, such as batch processing, rendering, build agents, test environments and stateless background workers.
Spot capacity is a standby airline ticket: much cheaper than a regular fare, but you may be asked to give up your seat if a full-fare passenger arrives. If you can travel flexibly, it is a bargain. If you must reach a wedding on time, it is a gamble.
Eviction and What You Can Do About It
When Azure needs the capacity back, it evicts an instance. You choose what happens: the instance can be deallocated, keeping its disks so it may be restarted later when capacity returns, or deleted completely. Instances receive a short advance warning, around thirty seconds, through a scheduled events service available from inside the machine. Your software can listen for it and use those seconds to save state, finish a task or hand work back to a queue. Design interruptible workers around this: small units of work, results saved often and unfinished work returned automatically.
Warning Appears
The instance receives an eviction notice through the scheduled events endpoint with a short countdown.
Drain and Save
The worker stops taking new jobs, saves progress and returns unfinished work to the queue.
Eviction Happens
The instance is deallocated or deleted according to your policy.
Capacity Is Refilled
The scale set tries to bring the count back to the target, possibly using another size or zone if you allowed it.
Mixing Spot and On-demand
Flexible orchestration can mix Spot and regular instances in one scale set, using a priority mix. For example, you can keep a base of on-demand instances that always run, and scale additional capacity as Spot for cost savings. This gives a stable minimum with cheap elasticity on top. Uniform orchestration cannot mix them in one set, which is one practical reason to choose Flexible for cost-sensitive fleets.
Advantages of Spot
- Large discounts compared with regular pricing
- Ideal for batch and background work
- Combine with on-demand for a stable base
- Can use many sizes to find spare capacity
Trade-offs of Spot
- Instances can be evicted at short notice
- No availability guarantee for the Spot portion
- Needs interruptible, restartable design
- Capacity and pricing vary by region and size
Running a stateful database or a single-instance critical service on Spot to save money. The first eviction becomes an outage. Use Spot only for work that can be paused and resumed elsewhere.
12Security: Defense in Depth
Because you own everything inside the virtual machine, security is largely your responsibility. Layers protect you when one fails.
A castle is not protected only by its gate. It has a moat, walls, guards, locked doors and a vault. If one layer fails, the next still holds. A fleet of servers needs the same layered thinking.
Layer 1: Network Exposure
Give instances no public addresses unless there is a clear reason. Put a load balancer or gateway in front, use network security groups to allow only required traffic and keep remote login ports closed to the internet. Use a bastion service, a private link or just-in-time access for administration. Use private endpoints for databases and storage so traffic never crosses the public internet.
Layer 2: Identity Without Passwords
Use managed identities so instances can call Azure services without stored credentials. In Flexible orchestration, user-assigned identities are the supported choice. Grant the narrowest role at the narrowest scope: an instance that only reads one storage container should not hold rights over the whole subscription. Retrieve secrets at runtime from a key vault using that identity, never from scripts, image files or plain settings.
Layer 3: The Machine Itself
Harden the image: remove unneeded software, disable unused services, apply security baselines and keep everything patched. Use trusted launch features where available to protect against boot-level tampering. Encrypt disks, and consider confidential options for highly sensitive data. Because you rebuild images regularly, new security fixes reach the fleet through new image versions, which is far more reliable than patching machines one by one.
Layer 4: Patching and Vulnerability Management
Patching is a continuing duty, not a one-time task. Flexible scale sets rely on in-guest patching tools and on regularly replacing instances with a fresh image, since automatic operating system image upgrades are not available there. Track the age of the oldest running image, scan for vulnerabilities and set a rule such as no instance older than thirty days. Combine this with rolling replacement so patching does not mean downtime.
No Public Addresses
Reach instances through gateways, bastion or private links only.
Managed Identity
Use identities instead of passwords, with narrow permissions.
Hardened Images
Minimal, patched images with baselines applied and versions tracked.
Encryption
Disks encrypted, traffic over TLS, secrets in a vault.
Rolling Refresh
Replace instances with new images on a schedule, keeping the oldest age low.
Detection
Central logs, security alerts and monitoring of administrative actions.
Believing that because Azure runs the datacenter, the virtual machines are secured for you. Azure protects the platform. The operating system, the software and the configuration inside every instance belong to you.
Governance Guardrails
Use Azure Policy to require approved images, block public addresses on interfaces, enforce encryption and require tags. Use role-based access control so only a few people can change models, capacity limits or network settings. Because a scale set can create hundreds of machines, permissions over its capacity are also permissions over your bill.
Problem
Each instance has a public address and open remote login access, with shared administrator passwords stored in scripts.
Why It’s Harmful
The fleet is exposed to constant automated attacks, a single leaked password opens every machine and there is no record of who did what.
Correct Approach
Remove public addresses, use a bastion or private access with identity-based login, store no shared passwords and log administrative sessions.
Disk Encryption and Trusted Launch
Data on disks is encrypted at rest by default with platform-managed keys. For stricter requirements you can bring your own keys held in a key vault, or add encryption at the host level, which also covers temporary disks and caches. Trusted launch adds secure boot and a virtual trusted platform module, helping detect tampering with the boot process, and works best when your images support it. Decide which level you need early, because some of these choices are easier to set when creating the model than to retrofit across a running fleet.
Platform-managed Keys
The default. No effort, suitable for many workloads, with Azure handling key management and rotation.
Customer-managed Keys
You hold the keys in a vault and control rotation and revocation. Suitable for regulated data, at the price of more operational responsibility.
Host-level Encryption
Extends encryption to temporary and cached data on the host, closing a gap that disk-level encryption alone may leave.
13Reliability, Disaster Recovery and Graceful Termination
Reliability is the art of staying useful when something breaks, because something always breaks.
Layers of Protection
| Design | Protects Against | Cost and Effort |
|---|---|---|
| Single instance | Almost nothing | Lowest |
| Several instances in one zone, spread over fault domains | Equipment and rack failures | Low |
| Instances across multiple zones | Whole datacenter failure | Medium |
| Multi-region with global routing | Whole region failure | High |
Multi-Region Designs
For regional outages or global audiences, run scale sets in two or more regions, with images replicated to each region through the compute gallery, and place a global router such as Azure Front Door or Traffic Manager in front. You can run all regions actively or keep one on standby at low capacity, scaling up when needed. Data replication is the hard part. Your database or storage must replicate across regions, or the second region has nothing meaningful to serve.
flowchart TD
U["Global Users"] --> FD["Front Door or Traffic Manager"]
FD --> R1["Region A Scale Set"]
FD --> R2["Region B Scale Set"]
GAL["Compute Gallery image replicated to both regions"] -.-> R1
GAL -.-> R2
R1 --> D1["Primary Database"]
R2 --> D2["Replica Database"]
D1 -. replication .-> D2
R1 --> M["Central Monitoring Workspace"]
R2 --> M
Backup and Site Recovery
Flexible scale sets support Azure Backup and Site Recovery, which Uniform sets do not. If your instances hold state, such as data disks that matter, backup gives you recovery points. Yet the preferred design is a stateless fleet with state in managed services, so a lost instance is simply replaced. Whatever you choose, rehearse recovery. A backup that has never been restored is only a hope.
Recovery Targets
Two numbers guide every recovery plan. The recovery time objective is how long you can be down. The recovery point objective is how much recent data you can afford to lose. Choose the cheapest design that meets those numbers, not the fanciest one. A fleet for an internal tool may accept hours of downtime, while a payment path may accept seconds.
Graceful Termination
Instances disappear for many reasons: scale-in, repairs, upgrades, host maintenance and Spot eviction. Each time, your software should drain gracefully. Stop accepting new connections, finish work in flight, flush buffers and close cleanly. The platform can send scheduled events ahead of some terminations, giving your code a few moments to prepare. Combine this with load balancer connection draining so users are not cut off mid-request.
A graceful termination is a shop closing for the night: the sign flips to closed, customers already inside finish their purchases, the till is counted and the lights go off. An abrupt termination is the power being cut while a customer is at the register.
Rehearse failure on purpose. Delete an instance, block a zone in a test environment and watch how the fleet reacts. A resilience plan that has never been tested is a document, not a capability.
A Simple Recovery Runbook
Write down, in plain steps, what to do when a zone or region fails. Who decides to fail over? How is traffic shifted? Which scale set in the other region must be scaled up, and how long does that take? Where are the latest image versions? Which database replica becomes primary, and how are applications told? A runbook that has been rehearsed twice is worth more than an elegant diagram nobody has tested. Review it after every significant change to the architecture, because plans rot quickly when networks, images and identities change.
14Monitoring, Logging and Diagnostics
You cannot fix what you cannot see. Fleets multiply every blind spot by the number of instances.
Three Kinds of Signals
Metrics
Numbers over time, such as CPU, memory, disk, network, instance count and request rate. Cheap, fast and ideal for alerts and autoscale.
Logs
Records of events from the operating system, the application and the platform. Ideal for finding exact causes.
Traces
The path of one request across services, showing where time is spent.
Metrics are the dashboard lights, logs are the service diary and traces are the footage of one specific journey. A good mechanic wants all three when something rattles.
Host Metrics and Guest Metrics
The platform reports host-level metrics, such as CPU percentage, without anything installed. Deeper insight, such as memory use, disk space, process details and operating system logs, requires a monitoring agent inside each instance. Include the agent in your image or configuration, point it at a central workspace and make sure every new instance reports from its first minutes. Instances created by autoscale are the ones most likely to be missing an agent if you forgot to automate it.
Watching the Fleet, Not Just the Machine
| Signal | Why It Matters |
|---|---|
| Instance count over time | Explains cost and shows whether autoscale is flapping |
| Average and maximum CPU and memory | The maximum reveals a single hot instance hidden by the average |
| Unhealthy and repaired instance counts | Rising numbers mean a hidden fault or a bad release |
| Autoscale activity log | Shows what rules fired and why, or why they failed |
| Allocation failures and quota usage | Warns before scale-out is blocked |
| Oldest image version running | Tracks patching hygiene and model drift |
| Boot time to healthy | Tells you how early to scale and how long cooldowns should be |
Alert Design
Urgent Page
Healthy instance count below minimum, error rate high or an entire zone unavailable.
Working-hours Ticket
Slow drift: image age rising, repeated single-instance repairs or growing boot time.
Capacity Warning
Instance count near the autoscale maximum or the regional core quota.
Cost Signal
Instance count or spend far above normal for the time of day.
Watching only the average CPU of the whole fleet. One instance at ninety-nine percent and nine at ten percent average out to a calm-looking nineteen. Always look at the worst instance as well as the average.
Diagnosing a Boot That Never Finishes
When a new instance never becomes healthy, work through the layers: did the instance get created, did it boot, did the extensions finish, did the application start and does the health endpoint answer? Boot diagnostics, serial console access and extension status messages usually point to the stuck layer. For Flexible scale sets, use the standard virtual machine tools for these checks, because the scale set specific batch tools do not apply.
Building a Log Pipeline That Survives Scale-in
When an instance is removed, whatever logs it held on its own disk are lost. Ship logs off the machine continuously, so the last minutes before a failure are never trapped on a disk that is about to be deleted. Configure the monitoring agent to send operating system and application logs to a central workspace, tag each record with the scale set name, instance name, zone and image version, and keep retention long enough for incident reviews. With these tags, you can answer questions such as whether errors cluster in one zone or on one image version in seconds rather than hours.
15Design Patterns and Anti-patterns
Patterns are proven shapes. Anti-patterns are the shapes that keep causing incidents.
Helpful Patterns
Immutable Infrastructure
Never change running instances. Build a new image for every change and replace instances with it. Every instance is then a known quantity, and rollback means going back to the previous image version.
Stateless Web Tier
Keep sessions, uploads and data outside the instances, in caches, databases and storage. Any instance can then serve any request, and scale-in becomes harmless.
Queue-Based Worker Fleet
Workers pull jobs from a queue and autoscale on queue length. Spot instances fit this pattern well, because unfinished work simply returns to the queue.
Blue-Green Fleet Replacement
Build a complete new scale set with the new image, shift traffic gradually, and retire the old one once stable. Useful for large changes, operating system upgrades and orchestration mode migrations.
Base Plus Burst
Keep a base of regular instances for steady load and add Spot or scheduled instances for peaks, balancing reliability and cost.
Hub and Spoke Network
Place firewalls, DNS and shared connectivity in a central hub network, with scale sets in spoke networks. Outbound traffic can be forced through the hub for inspection.
Anti-patterns to Avoid
Problem
Instances keep important data on local disks, such as uploaded files, session data or the only copy of a database.
Why It’s Harmful
Scale-in, repair, upgrade or eviction deletes the data. Users see missing files and logged-out sessions, and recovery is impossible.
Correct Approach
Use external stateful services and treat instance disks as disposable scratch space.
Problem
The scale set has a minimum of one instance in a single zone, with no health checks or alerts.
Why It’s Harmful
Any maintenance event, zone problem or crash becomes an outage that nobody notices until customers complain.
Correct Approach
Use at least two instances across zones, configure health checks and repairs, and alert on healthy instance count.
Problem
The model points to the latest image version, and a new image is published without testing.
Why It’s Harmful
The next scale-out launches instances running an untested image, so the fleet gradually becomes a mix of good and bad machines, and the problem looks random.
Correct Approach
Pin specific image versions in production, test new versions in a staging fleet and promote deliberately.
16Cost Optimization and Governance
The cloud bill is an architecture diagram written in money. Reading it well saves real budget.
How a Fleet Is Billed
The scale set feature itself is free. You pay for what it creates: the virtual machines for every second or hour they exist, the disks attached to them, the load balancer or gateway, the NAT gateway, public addresses, data leaving the region, monitoring data and any licenses bundled with the images. A stopped but not deallocated machine still costs compute. A deallocated machine stops compute charges but its disks continue to cost money. Because the bill grows with instance count and time, the main levers are how many instances run, how big they are and how long they stay.
Paying for a fleet is like renting taxis by the hour. Each car costs money whether or not it has a passenger. You save by renting fewer cars at quiet times, choosing the right size of car, and using cheaper standby cars for flexible jobs.
Levers to Spend Less
Right-size Machines
Review CPU and memory trends. If instances idle at fifteen percent, a smaller size or fewer instances will do.
Schedule Down
Use schedule-based autoscale to reduce capacity at night and weekends for internal and test workloads.
Use Spot for Flexible Work
Run batch and stateless background workers on Spot capacity at a deep discount.
Commit for the Steady Base
For capacity that always runs, reservations or savings plans lower the hourly rate in return for a commitment.
Choose Ephemeral Disks
For stateless instances, local ephemeral disks avoid storage charges and speed up resets.
Clean Up Orphans
Delete unattached disks, unused public addresses, forgotten test scale sets and old image versions.
The Break-even Question: Fleet or Platform Service?
A scale set gives full control but includes all the operating system work. For a standard web application, a platform service may need less labor, and labor is also a cost. Compare the full cost, including patching, image building, monitoring setup and incident time, not just the hourly price of virtual machines. A fleet makes the most economic sense when you truly need machine-level control, special software or licensing, or when scale and utilization are high enough that the control is worth the effort.
Quotas and Governance
Every subscription has core quotas per region and per machine family. A scale set that tries to exceed them fails to scale, usually at the worst moment. Check quotas before launches and request increases early. For governance, use Azure Policy to require tags, approved images and approved sizes, and to block public addresses. Use budgets and cost alerts so a runaway autoscale loop becomes a notification, not a month-end shock.
Create an alert on instance count that fires when it exceeds a normal ceiling for your workload. A sudden jump is almost always a flapping rule, a metric gone wrong or an attack, and finding it in minutes can save a large bill.
Licensing and Special Workloads
Some fleets run licensed software, and licensing can silently become the largest cost. Check whether the license is per machine, per core or per user, and whether it can follow instances that appear and disappear automatically. Azure offers ways to bring existing operating system and database licenses to virtual machines, which can reduce hourly rates, but they require careful tracking so that you stay compliant as the fleet scales. For graphics, machine learning or high-memory workloads, remember that specialized machine families have extra constraints, tighter capacity and sometimes limits on how they can be updated, so test scale-out for those sizes early instead of assuming they behave like general purpose ones.
17Real-World Examples and Choosing Alternatives
Patterns become clear when you see how different organizations shape the same service for different goals.
Industry Scenarios
Seasonal Retail Platform
An online retailer runs web and API fleets across three zones behind an application gateway with a web application firewall. Schedule-based rules add capacity before each sale, metric rules handle surprises, and the images are pinned and promoted through test environments. After the season, the fleet shrinks and costs fall.
Rendering and Simulation
A studio renders frames on large fleets of Spot instances. Jobs are small and results are saved often, so evictions barely matter. A base of regular instances handles the schedule-critical work while Spot soaks up the rest at a deep discount.
Build and Test Agents
A development organization runs build agents in a scale set that grows with queue length. Fresh instances from a clean image avoid leftover state, and instances are deleted after each job, so builds are repeatable.
Multiplayer Game Servers
A game company scales server capacity with the number of active matches. Instances start from a prepared image so a match server is ready in minutes, and regional fleets keep latency low for players.
Regulated Back-End Services
A financial firm runs licensed software that must run on virtual machines. Fleets sit in private subnets with no public addresses, private endpoints, managed identities, hardened images, rolling replacement and full audit logs.
Scale Sets Versus Other Compute Choices
| Need | Best Fit | Why |
|---|---|---|
| Fleet of similar machines with full operating system control | Virtual Machine Scale Sets | Elastic scale, zone spread and machine-level control |
| Standard web app or API without server chores | App Service | Managed platform with deployment slots and built-in scaling |
| Small event-driven code with bursty load | Azure Functions | Pay per use, no machines to manage |
| Containerized microservices without cluster work | Container Apps | Container-native with event-driven scaling |
| Large container platforms with deep orchestration needs | Kubernetes Service | Maximum control, built on node pools backed by scale sets |
| Large batch and high-performance computing jobs | Azure Batch or a scale set with a job scheduler | Job scheduling and pooled compute |
| One-off special server | A single virtual machine | Not a fleet, so a scale set adds little |
Choosing virtual machines because they feel familiar, then spending most of the team’s time patching, imaging and monitoring them. Choose the lowest level of control that meets your real requirements.
Moving From Availability Sets or Uniform Sets
Many teams arrive with virtual machines in availability sets or with Uniform scale sets. There is no automatic converter. A calm migration follows a pattern. Assess the current estate: images, extensions, networking, identity, outbound needs and state on disks. Build the Flexible target with templates, including explicit outbound connectivity and health extension setup. Test with realistic traffic. Shift users in steps through a shared load balancer or gateway, watch metrics and keep the old fleet ready for an instant return. Retire the old resources only after a full business cycle without problems.
Assess
List images, extensions, networks, identities, outbound dependencies and any local state on disks.
Rebuild the Template
Define a Flexible set with an explicit fault domain count, no NAT pools and a clear outbound design.
Test Under Load
Validate autoscale-created instances, health checks, repairs and logging with production-like traffic.
Shift Traffic Gradually
Add the new set to the shared load balancer and move a small share first, then more.
Retire the Old Fleet
Scale down and remove the old resources after stable operation, and record lessons.
18Best Practices and Common Mistakes
A compact checklist for design reviews.
Do These
- Choose Flexible orchestration for new scale sets unless a platform requires Uniform
- Spread instances across at least two zones, with a minimum of two instances
- Bake dependencies into a pinned, tested image version
- Configure health checks and automatic repairs with a realistic grace period
- Provide explicit outbound connectivity, such as a NAT gateway
- Use managed identities and keep secrets in a vault
- Keep state outside instances and drain gracefully on termination
- Set autoscale minimum, maximum and wide threshold gaps
- Monitor instance count, boot time and the oldest image age
Avoid These
- Fixing running instances by hand
- Installing software from the internet at every boot
- Public addresses and open remote login on instances
- Autoscale on a single metric with tiny threshold gaps
- One rare machine size in one zone
- Running stateful or critical single points on Spot
- Using the latest image version in production without testing
- Watching only the fleet average
- Assuming Uniform settings carry over to Flexible
A Maturity Ladder
Working
A Flexible scale set behind a load balancer, with a custom image and basic metric alerts.
Resilient
Zones, health checks, repairs, graceful termination and tested autoscale rules.
Secure and Private
No public addresses, managed identities, private endpoints, hardened images and rolling refresh.
Optimized and Governed
Spot and committed capacity, policy-enforced standards, cost alerts, multi-region design and rehearsed recovery.
Testing Before You Trust
Test the behaviors that only show up under stress. Force a scale-out and measure the time from decision to healthy traffic. Delete an instance and watch repairs. Make the health endpoint fail and watch the grace period. Simulate a zone loss in a test environment. Publish a deliberately broken image to a staging fleet and see whether the rolling update stops itself. These rehearsals turn assumptions about the fleet into known facts.
19Frequently Asked Questions
Short, practical answers to questions that come up again and again.
No. The orchestration mode is fixed when the scale set is created. Migrate by building a new Flexible set and shifting traffic, using a blue-green approach.
No. The scale set itself is free. You pay for the virtual machines, disks, networking, monitoring and other resources it uses.
Flexible scale sets provide no default outbound access. Add explicit outbound connectivity, such as a NAT gateway, a firewall route or load balancer outbound rules.
Each new instance must be allocated, booted, configured and health-checked. Shorten it with prepared images and minimal startup work, and scale earlier or on a schedule.
Up to 1,000 virtual machines with fault domain guarantees. Check the current limits page, because some constraints apply to special machine families, and your regional quota may be lower.
The thresholds are probably too close, the window too short or the cooldown shorter than boot time. Widen the gap, lengthen the window and match cooldown to your real startup time.
Yes in Flexible orchestration, which supports a mix of Spot and on-demand. Uniform orchestration uses one or the other.
No. Use in-guest patching and replace instances or whole scale sets with newer images on a regular schedule.
AKS and Service Fabric are listed as not supported on Flexible orchestration, so those platforms use Uniform sets. Check current documentation before planning.
If an instance stays unhealthy past the grace period, the platform performs your chosen repair action, such as replacing it. It depends on a reliable health signal, so configure the health extension or probe carefully.
Bake slow-changing software into the image for speed and reliability. Keep boot-time configuration small and quick, such as environment names and secret retrieval.
A Flexible set with at least two instances across zones, a pinned golden image, health checks and repairs, schedule and metric autoscale with a maximum, explicit outbound access and alerts on instance count. Add Spot or commitments for the parts that suit them.
20Summary and Key Takeaways
Virtual Machine Scale Sets turn one machine blueprint into an elastic, spread-out fleet. Behind that simple idea sit choices that matter: the orchestration mode, which cannot be changed later and where Flexible is now the recommended path; the image strategy that decides boot speed and consistency; autoscale rules that need wide gaps and honest cooldowns; zone and fault domain spreading that creates real resilience; health checks that make repairs and updates safe; and networking that, in Flexible sets, demands explicit outbound design. Security remains yours inside every instance, so hardened images, identities without passwords and rolling replacement are essential. Above all, treat every instance as disposable, keep state elsewhere, observe the whole fleet and choose the lowest level of control that meets your real needs.
Key Takeaways
- Choose the mode deliberately — orchestration mode is fixed at creation, Flexible is recommended for new sets, and migration from Uniform or availability sets is a rebuild using blue-green.
- Bake, do not improvise at boot — prepared, versioned images from a compute gallery give fast, consistent scale-out, and pinned versions make releases predictable.
- Autoscale with discipline — pair rules with wide gaps, sensible windows, cooldowns longer than boot time, and clear minimum and maximum limits, plus schedules or prediction for known patterns.
- Spread for real resilience — use multiple zones and fault domains, keep at least two instances, diversify sizes and plan for allocation failures and quotas.
- Let health drive repair and updates — configure realistic health checks and grace periods, roll out images in batches and alert on repeated repairs.
- Design the network on purpose — no public addresses on instances, explicit outbound connectivity in Flexible sets, private endpoints and correct subnet sizing.
- Keep instances disposable and governed — store state outside, drain gracefully, use Spot only for interruptible work, and watch cost with tags, budgets and instance-count alerts.