Creating a Virtual Machine Scale Set from a captured image
What is a Virtual Machine Scale Set (VMSS)
It is a high-availability service provided by Microsoft Azure that enables you to deploy and manage a group of identical virtual machines (VMs) as a single unit. VMSS is designed to simplify the deployment and management of applications that require scalability, high availability, and load balancing.
Why use Virtual Machine Scale Sets?
To provide redundancy and improved performance, applications are typically distributed across multiple instances. Customers may access your application through a load balancer that distributes requests to one of the application instances. If you need to perform maintenance or update an application instance, your customers must be distributed to another available application instance. To keep up with extra customer demand, you may need to increase the number of application instances that run your application.
Azure Virtual Machine Scale Sets provide management capabilities for applications that run across many VMs, automatic scaling of resources, and load balancing of traffic. Scale sets provide the following key benefits:
Scalability: VMSS allows you to automatically adjust the number of VM instances in the scale set based on metrics like CPU utilization, memory usage, or custom-defined application metrics. This automatic scaling ensures that your application can handle varying workloads efficiently.
Load Balancing: VMSS instances are automatically load-balanced, distributing incoming network traffic across all VM instances in the scale set. This helps improve the availability and performance of your application.
High Availability: VMSS distributes VM instances across multiple fault domains and updates domains to ensure high availability. In the event of hardware failures or planned maintenance, your application remains accessible.
Rolling Updates: You can perform rolling updates on VMSS instances to apply OS updates, security patches, or application changes without causing downtime. VM instances are updated in small batches to maintain application availability.
Custom Images: You can create custom VM images with the desired configuration and software stack, which can be used to deploy VM instances within the scale set. This allows you to maintain consistency across VM instances.
Automatic Instance Replacement: VMSS monitors the health of individual VM instances. If an instance becomes unhealthy due to application issues, it can be automatically replaced to maintain the desired level of availability.
Integration with Azure Services: VMSS integrates seamlessly with other Azure services like Azure Load Balancer, Azure Monitor, Azure Auto-Scaling, and Azure Virtual Network, allowing you to build comprehensive and resilient cloud applications.
Stateless Workloads: VMSS is particularly well-suited for stateless workloads like web applications, microservices, and batch processing, where multiple identical instances can serve requests independently.
Global Deployment: You can deploy VMSS instances in multiple Azure regions to build globally distributed applications, ensuring low latency access for users worldwide.
Cost Optimization: VMSS helps optimize costs by automatically scaling down during periods of low demand and scaling up when demand increases, ensuring that you only pay for the resources you need.
Azure Virtual Machine Scale Sets provide a powerful tool for achieving scalability and high availability for your applications in the Azure cloud. They simplify infrastructure management and allow you to focus on delivering a reliable and performance application to your users.
The first thing is to go to the Azure portal. This article is a follow-up to the previous one, where I captured the Windows VM "Creating a compute gallery and capture the Image VM".
As shown in the diagram below, you click on Create VMSS after capturing the image.
Under orchestration, I chose flexible, as shown in the diagram below
There are two orchestration modes in VMSS:
Uniform orchestration mode is optimized for stateless workloads with identical instances. In this mode, the scale set creates and manages a set of identical VMs. You cannot manage individual VMs in a uniform scale set.
Flexible orchestration mode is optimized for stateful workloads and workloads that require high availability. In this mode, the scale set creates and manages a set of VMs that can be different from each other. You can manage individual VMs on a flexible scale.
The main difference between the two modes is that uniform orchestration mode hides the individual VMs from you, while flexible orchestration mode exposes them. This means that in uniform orchestration mode, you can only manage the scale set as a whole, while in flexible orchestration mode, you can manage individual VMs.
In the context of VMSS, a stateful workload is one that maintains state between VM instances. This means that the state of the workload, such as data or configuration, is stored on the VM's disks. If a VM instance is replaced or fails, the state of the workload must be restored to the new VM instance.
A stateless workload, on the other hand, does not maintain state between VM instances. This means that the state of the workload is not stored on the VM's disks. If a VM instance is replaced or fails, the workload can be restarted on a new VM instance without any loss of state.
Here are some examples of stateful workloads:
Databases
File servers
Message queues
Distributed applications
Here are some examples of stateless workloads:
Web servers
Load balancers
Content delivery networks
Batch processing jobs
The type of workload you have will determine the best orchestration mode for you. If you have a stateful workload, then you should use flexible orchestration mode. This will ensure that the state of your workload is preserved if a VM instance is replaced or fails.
If you have a stateless workload, then you can use either uniform or flexible orchestration modes. Uniform orchestration mode is simpler to manage, but flexible orchestration mode gives you more control.
Under the Administrator account, As shown in the diagram below, the username and password are blanked out because we chose the specialized VM when capturing our Windows VM image.
Accept the license agreement.
What is a Load Balancer in VMSS Creation:
Azure Load Balancer is a highly available and scalable network load-balancing service provided by Microsoft Azure. It plays a crucial role in distributing incoming network traffic across multiple virtual machines (VMs) or instances to ensure the high availability, reliability, and scalability of applications hosted on Azure. Azure Load Balancer is a critical component for ensuring the availability and scalability of applications and services hosted on the Azure cloud platform. It can be used for a wide range of scenarios, from web applications to multi-tiered architectures, and helps maintain a high level of service availability for your applications. Scroll down to create a load balancer.
On the Scaling policy option, select custom scaling policy to enable auto-scaling of instances based on metrics that will be predetermined. Otherwise, choose the Manual scaling policy option.
A custom scaling policy allows you to control how your Virtual Machine Scale Set (VMSS) scales in and out. You can use these options to scale your VMSS based on a variety of factors, such as CPU usage, memory usage, or disk I/O.
Instance count is the number of instances in the scale set.
The minimum value for autoscale on this scale set is
The maximum value for autoscale on this scale set
The CPU usage percentage threshold for triggering the scale-out autoscale rule
Duration: This is the amount of time that the Autoscale engine will look back for metrics. For example, 10 minutes means that every time autoscale runs, it will query metrics for the past 10 minutes. This allows your metrics to stabilize and avoid reacting to transient spikes. The Storage queue Approximate Message Count and Service Bus Message Count metrics are special in that these metrics are point-in-time only and have no history. For these metrics, the duration field will be ignored by the Autoscale engine.
Number of instances to increase by: the number of virtual machine instances to add to the scale set when the scale-out autoscale rule is triggered.
Number of instances to decrease by: The number of virtual machine instances to remove from the scale set when the scale in the autoscale rule is triggered.
Leave every configuration to default and click next to review and create
NB: You could add Tags if deemed necessary.
Validation must be passed and submitting deployment will be noticed in the notification corner at the top right as seen below.
Deployment in Progress...
Go to resource once the deployment is completed
Our VMss is completed and Deployed successfully
In the diagram below, you will find the data disk already attached to the first VM in the VMSS.
All things being equal, you should have the same configuration on both the Parent VM and each of the Instances in the VMSS.
Clean up resources
When no longer needed, delete the resource group, scale set, and all related resources. To do so, select the resource group for the scale set and then select Delete.
This is the end of the Virtual Machine Scale Set learning. I hope you found this learning informative. Stay tuned for other Interesting and informative topics on Azure cloud infrastructure.
Subscribe to my newsletter
Read articles from Yinusa Kolawole directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by