What is VMSS ?
Azure virtual machines is appropriate service for the on-premise applications which immediately want to move to cloud, enabling
lift-and-shift kind of migration. But let’s say this application needs to run behind a load balancer. In order to support this scenario, you will have to:
- create a load balancer,
- then manually create multiple virtual machines
- then configure monitoring,
- Manage each resource separately etc.
In addition, you will also need to provision all the virtual machines together at once. What if your application has high load only for few hours every day and you want to configure dynamic scaling ? It is not possible.
Here comes VMSS for rescue. Virtual machine scale sets (VMSS) lets you create group of identical, load balanced virtual machines. The number of virtual machine instances can increase or decrease in response to load dynamically. OR this scaling can also be scheduled.
Why to use it ?
There can be a number of reasons why VMSS can be preferred. Below are some of the important reasons:
- High Availability and Resiliency, multiple instances of virtual machines can be spawned instantly and hence enabling application to be available even when demand is high. Also, the virtual machine instances can be distributed among various Availability Zones to different data centers or availability zones
- Dynamic scaling, rules can be configured to spawn the instances when demand is high and scaling down when demand is again low. The number of instances can also be configured to change based on schedule. Both these options can be helpful for saving some costs as you do not need to create all the virtual machines upfront.
- Ability to serve large scale applications, a virtual machine scale set can scale upto 1000 virtual machines instances.
Create Load Balancer
On create new load balancer panel, provide below inputs:
- Subscription, a valid Azure subscription
- Resource Group, logical container for the resource
- Name, any valid name, e.g. my-load-balancer
- Region, Azure region where the resource would be located
- Type, this can be internal or public. Select public for this demo.
- SKU, the pricing tier. Select Standard tier.
- Public IP Address, select create new option.
- Public IP Address Name, any valid name, e.g. my-public-ip
- Assignment, select static assignment
Then click on Review + Create button, which will initiate the validation. Once validation is successful, hit Create button to create the load balancer.
On new panel, provide below inputs in Basics tab:
- Subscription, a valid subscription
- Resource Group, a valid logical container. Provide the same which was created for load balancer in previous step, so that cleanup is easy.
- Virtual machine scale set name, a valid name for VMSS
- Region, an Azure region where this resource will be located physically
- Availability zone, unique physical location within an Azure region. I have selected zone 1 and 2.
- Image, the operating system for the virtual machines
- Azure spot instance, select NO here.
- Size, keep it default for this demo
Then select password authentication and provide username password which can be used to connect. Then click on Next button.
On Disks tab, keep the defaults and click on Next button.
- In Load balancing options, select Azure load balancer.
- In Select a load balancer, select my-first-load-balancer that you created earlier.
- For Select a backend pool, select Create new, type my-backend-pool, then select Create.
When you are done, select Review + create. After validation is passed, then click on create button.
|## Create resource group in your preferred location|
|az group create –name myResourceGroup –location westeurope|
|## Command to create VMSS|
|## provide resource group name, and vmss name|
|## Load balance would automatically be created|
|az vmss create \|
|–resource-group myResourceGroup \|
|–name my-first-vmss \|
|–image UbuntuLTS \|
|–upgrade-policy-mode automatic \|
|–admin-username azureuser \|
I hope you enjoyed this article. Let me know your thoughts.