Understanding Azure Virtual Machine Scale Sets (VMSS) and How to Create It using Azure portal.
Published: 2024-04-29 12:23:32

Virtual Machine Scale Sets (VMSS) is an interesting service offered by Microsoft Azure, it helps to create and manage a set of identical, auto-scaling Virtual Machines (VMs). The number of VM instances can automatically increase or decrease based on scheduled conditions. 

Azure Virtual Machine Scale Sets lets you create and manage a group of load balanced VMs whose number of VM instances can automatically increase or decrease in response to demand or based on a defined schedule. It has the following Advantages.

- Easy to create and manage multiple VMs
- Provides high availability and application resiliency by distributing VMs across availability zones or fault domains
- Allows your application to automatically scale as resource demand changes
- Works at large-scale

A scale set can be deployed with a Windows image or Linux image such as RHEL, CentOS, Ubuntu, or SLES.

## Creating a Windows Virtual Machine Scale Set

_In the Azure portal search bar, search for and select Virtual Machine Scale Sets._

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nbv49ll3j9iezws4phqr.png)

Select Create on the Virtual Machine Scale Sets page.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hly7djfwc14mq9szlfxu.png)

In the Basics tab, under Project details, make sure the correct subscription is selected and create a new resource group.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hzfdbrtbuewp1osmxq2i.png)

Under Scale set details, enter your scale set name and select a Region that is close to your area.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hmpho7c5kziq4z7gly3a.png)

Under Orchestration, select Flexible.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1p9fy1wdzbmmdo5xebzc.png)

Under Scaling mode select Auto scaling and set up the scaling conditions.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dx512gwjubmv11t7fz5n.png)

_Under Instance details, select a marketplace image for Image. Select any of the Supported Distros_.

_Under Administrator account configure the admin username and set up an associated password. _

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5v48e9v6jhbf8sx2glnk.png)

Select Next: Disks to move the disk configuration options. For this quickstart, leave the default disk configurations.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d3sam9een1uymhb4kxfz.png)

Select Next: Networking to move the networking configuration options.

_On the Networking page, under Load balancing, select the Use a load balancer checkbox to put the scale set instances behind a load balancer._

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jg0aetazzj1lxbrunefr.png)

_In Load balancing options, select Azure load balancer.
_
_In Select a load balancer, select a load balancer or create a new one._

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6sciac6rot4w4hwdk9o3.png)

_select Create new, type the name then select Create._

_When done select Review + create._

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5u2tquayeoo0m71sd6sl.png)

_After it passes validation, select Create to deploy the scale set._

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d61wh6vz19vckhyz9w35.png)

_Wait for deployment to finish._

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2bpfpbq4xovje7jbi12i.png)

_Clik on Go to resources to view the deployment._

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8gy7zrk2jjkf2256q4my.png)

_The resources deployed are shown bellow_

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tdx8027mjpm35a3dcma9.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bp2o5wzq3wogjxz906yi.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/byuc38987i57f6ig59bp.png)

## Definition of Concepts

**What is Orchestration?**

Orchestration is the coordination and management of multiple computer systems, applications and/or services, stringing together multiple tasks in order to execute a larger workflow or process. These processes can consist of multiple tasks that are automated and can involve multiple systems.

The goal of orchestration is to streamline and optimize the execution of frequent, repeatable processes and thus to help easily manage complex tasks and workflows to save time, increase efficiency, and eliminate redundancies. 

**_Types of VMSS Orchestration: Uniform and Flexible_**
Azure VMSS provides two types of orchestration modes: Uniform and Flexible.

**Uniform Orchestration** is the traditional model of managing VMs in a scale set. All instances in the set are identical, ensuring uniform performance and simplifying management.

**Flexible Orchestration** allows for different types of instances within the same scale set. This adds complexity to management but provides flexibility in managing heterogeneous workloads where different VM sizes may be needed.

**What is Azure Load Balancer?**

Load balancing refers to efficiently distributing incoming network traffic across a group of backend servers or resources.
Load balancer distributes inbound flows that arrive at the load balancer's front end to backend pool instances. These flows are according to configured load-balancing rules and health probes. The backend pool instances can be Azure Virtual Machines or instances in a Virtual Machine Scale Set.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fmy78gdmw6tka24qe3aw.jpg)

_**A public load balancer**_ can provide outbound connections for virtual machines (VMs) inside your virtual network. These connections are accomplished by translating their private IP addresses to public IP addresses. Public Load Balancers are used to load balance internet traffic to your VMs.

_**An internal (or private) load balancer**_ is used where private IPs are needed at the frontend only. Internal load balancers are used to load balance traffic inside a virtual network. 

Diagram depicts public and internal load balancers directing traffic to web and business tiers.

**Why use Azure Load Balancer?**
With Azure Load Balancer, you can scale your applications and create highly available services. Load balancer supports both inbound and outbound scenarios. Load balancer provides low latency and high throughput, and scales up to millions of flows for all TCP and UDP applications.

Key scenarios that you can accomplish using Azure Standard Load Balancer include:

- Load balance internal and external traffic to Azure virtual machines.
- Pass-through load balancing which results in ultra-low latnecy.
- Increase availability by distributing resources within and across zones.
- Configure outbound connectivity for Azure virtual machines.
- Use health probes to monitor load-balanced resources.
- Employ port forwarding to access virtual machines in a virtual network by public IP address and port.
- Load balance services on multiple ports, multiple IP addresses, or both.

 **_Azure Virtual Machine scale-in policies_**
A Virtual Machine Scale Set deployment can be scaled-out or scaled-in based on an array of metrics, including platform and user-defined custom metrics. While a scale-out creates new virtual machines based on the scale set model, a scale-in affects running virtual machines that may have different configurations and/or functions as the scale set workload evolves.

The scale-in policy feature provides users a way to configure the order in which virtual machines are scaled-in, by way of three scale-in configurations:

**Uniform orchestration**
By default, Virtual Machine Scale Set applies this policy to determine which instance(s) will be scaled in. With the Default policy, VMs are selected for scale-in in the following order:

1. Balance virtual machines across availability zones (if the scale set is deployed in zonal configuration)
2. Balance virtual machines across fault domains (best effort)
3. Delete virtual machine with the highest instance ID
4. Users don't need to specify a scale-in policy if they just want the default ordering to be followed.

Balancing across availability zones or fault domains doesn't move instances across availability zones or fault domains. The balancing is achieved through deletion of virtual machines from the unbalanced availability zones or fault domains until the distribution of virtual machines becomes balanced.

**_NewestVM scale-in policy_**
This policy will delete the newest, or most recently created virtual machine in the scale set, after balancing VMs across availability zones (for zonal deployments). Enabling this policy requires a configuration change on the Virtual Machine Scale Set model.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jsf7g919qcnzlkwblyul.jpg)

**_OldestVM scale-in policy_**
This policy will delete the oldest created virtual machine in the scale set, after balancing VMs across availability zones (for zonal deployments). Enabling this policy requires a configuration change on the Virtual Machine Scale Set model.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6kjltv4kpd3k2wdarixr.jpg)