DEV Community

Cover image for Supercharge Your Infrastructure: Crafting Azure Virtual Machine Scale Sets from Captured VM Images in Azure Compute Gallery
Maxwell Ugochukwu
Maxwell Ugochukwu

Posted on

Supercharge Your Infrastructure: Crafting Azure Virtual Machine Scale Sets from Captured VM Images in Azure Compute Gallery

Introduction

In the ever-evolving world of cloud computing, scalability is key. Whether you're a startup gearing up for rapid growth or an established enterprise managing variable workloads, Azure Virtual Machine Scale Sets (VMSS) can be a game-changer. This versatile Azure service allows you to effortlessly manage and scale multiple virtual machines (VMs) while ensuring high availability and ease of management. In this award-winning blog, we'll walk you through creating a VMSS from a compute gallery in the Azure Portal, unlocking the potential for your applications to scale dynamically.

Why VMSS and Compute Gallery?

Before we dive into the steps, let's understand the significance of using VMSS with a compute gallery.

Azure Compute Gallery is a powerful feature that allows you to create and manage custom virtual machine images. These images can include your desired operating system, applications, and configurations. VMSS, on the other hand, is an Azure service that lets you deploy and manage a set of identical VMs. Combining these two technologies allows you to scale applications horizontally by deploying VMs based on custom images from the gallery.

Click Here to Learn How to Create a Compute Gallery and Capture a VM Image

Benefit of Azure Virtual Machine Scale Set

Azure Virtual Machine Scale Sets (VMSS) offer several benefits for managing and deploying virtual machines in Microsoft Azure:

  • High Availability: VMSS automatically distributes VM instances across multiple fault domains and update domains to ensure high availability. If a VM becomes unhealthy, it can be automatically replaced with a new one, reducing downtime.

  • Scalability: VMSS allows you to easily scale your applications up or down based on demand. You can define scaling rules to add or remove VM instances automatically, ensuring your application can handle varying workloads efficiently.

  • Automatic Updates: You can configure VMSS to perform rolling updates, ensuring that your VM instances are always up-to-date with the latest patches and software updates without causing downtime.

  • Custom Images: VMSS supports custom VM images, allowing you to create and configure a single VM, capture its image, and then use that image to scale out instances. This simplifies deployment and ensures consistency across VM instances.

  • Managed Disks: VMSS can use managed disks, providing features like automatic backups, replication, and enhanced reliability.

  • Auto Scaling: You can define auto-scaling rules based on performance metrics, such as CPU utilization or memory usage, to automatically adjust the number of VM instances to match your application's needs.

  • Integrated Monitoring: VMSS integrates with Azure Monitor, allowing you to collect and analyze performance data, set up alerts, and gain insights into the health and performance of your VM instances.

  • Cost-Efficiency: VMSS can help optimize costs by automatically scaling down when demand is low and scaling up when demand increases, ensuring you only pay for the resources you need.

  • **Ease of Management: **VMSS simplifies the management of a group of VMs. You can define a common configuration for all instances in the set and make changes centrally, reducing administrative overhead.

  • Rolling Upgrades: When you update the underlying image or configuration of your VM instances, VMSS can perform rolling upgrades to minimize application downtime and ensure a smooth update process.

  • Template-Based Deployment: You can use Azure Resource Manager (ARM) templates to define and deploy VMSS instances, making it easier to replicate your application environments consistently.

  • Integration with Azure DevOps: VMSS can be integrated into your CI/CD pipeline, allowing you to automate the deployment and scaling of your applications.

  • Global Deployment: You can use VMSS to deploy VM instances across multiple Azure regions, improving the resilience and availability of your applications.

Prerequisites

Before you begin, ensure that you have the following prerequisites in place:

Azure Subscription: You need an active Azure subscription. If you don't have one, you can sign up for a free trial at Azure Portal.

Azure Resource Group: Create an Azure Resource Group to organize and manage your gallery resources.

Azure Compute Gallery: Make sure you have created a compute gallery and have captured the image of the VM you want to scale. Click here to learn how to create a compute gallery and capture a VM.

Creating a VM Scale Set

Login to the Azure Portal home page.

Azure Portal

Click on 'Create a resource' and search for 'Virtual Machine Scale Set'. Select it.

Create a resource

Create a resource

Click on 'Create'.

Create

Basics: Fill out the basic information, such as the subscription, resource group, and region. Give your VMSS a unique name.

basic information

Orchestration: The orchestration mode is defined when you create the scale set and cannot be changed or updated later. There are two types in Azure, the Uniform and flexible orchestration. Scale sets with Uniform orchestration is Optimized for large-scale stateless workloads with identical instances while Scale sets with Flexible orchestration is used to achieve high availability at scale with identical or multiple virtual machine types.

Select the 'Flexible orchestration'; With Flexible orchestration, Azure provides a unified experience across the Azure VM ecosystem. Flexible orchestration offers high availability guarantees (up to 1000 VMs) by spreading VMs across fault domains in a region or within an Availability Zone. This enables you to scale out your application while maintaining fault domain isolation that is essential to run quorum-based or stateful workloads, including:

Quorum-based workloads
Open-source databases
Stateful applications
Services that require high availability and large scale
Services that want to mix virtual machine types or leverage Spot and on-demand VMs together
Existing Availability Set applications

Orchestration

Instance Details: Configure instance details, such as the VM image, VM architecture and instance size.

select the 'gallery image' you created earlier. This is where the power of Compute Gallery comes into play. You can choose the specific version you want to deploy.

gallery image

This will automatically select the VM architecture and VM size that was used in the VM we captured in our compute gallery.

gallery image

Administrator Account: This is where you setup the username and password of your VMSS, but because we selected the Specialised operating system state when we captured the VM image it is grayed out because we no longer need authentication when we want to scale out.

Make sure you choose a 'licensing type' and check the box to confirm you have an eligible windows license. For the purpose of the VMSS we are to scale, we optioned for 'windows server' since we are scaling out to manage network traffic.

licensing type

Scaling: Configure scaling options based on your application needs.

Scaling

Select 'Custom scaling' so that you can define scaling rules for automatic scaling. Here we define;

  • initial instance count to 2.
  • minimum number of instance to 1
  • maximum number of instance to 10
  • the VMSS to scale out in 5 minutes once the CPU threshold gets to 75% by 2 instances.
  • the VMSS to scale in, in 5 minutes once the CPU threshold gets to 25% by 2 instances.

custom scaling

custom scaling

Management: Specify monitoring, diagnostics, and auto-shutdown settings as per your requirements or leave it on default just like I did.

Tags: Ensure that your resources are tagged and you can add tags based on your preference.

Tags

Review + Create: Review your settings, and when everything looks good, click 'Create' to deploy your VM Scale Set.

Review + Create

Review + Create

This will take a while, Once deployment is completed, click on 'Go to resource' to access the newly created VMSS.

Go to resource

This is the newly deployed Virtual Machine Scale Set and you can see 2 initial instance defined during configuration are already running.

deployed

deployed

_Step 3: Monitor and Manage Your VMSS

Once your VMSS is deployed, you can use Azure Monitor and Azure Autoscale to ensure your application scales efficiently and is highly available. Azure Monitor helps you gain insights into your VMSS's performance, while Autoscale allows you to automate scaling based on metrics and schedules._

Conclusion

In this comprehensive guide, we've explored the process of creating a Virtual Machine Scale Set (VMSS) from a custom image in Azure Compute Gallery. By leveraging these Azure services, you can optimize the scalability and availability of your applications, ensuring they can handle varying workloads with ease.

VMSS and Compute Gallery are indispensable tools in your cloud infrastructure toolbox, empowering you to deploy, manage, and scale virtual machines efficiently. As you embark on your cloud journey, remember that flexibility and scalability are your allies, and Azure is your trusted partner in achieving your goals.

Embrace the power of Azure VMSS and Compute Gallery to unlock the true potential of your cloud applications. Scale up, scale out, and scale confidently with Microsoft Azure.

Top comments (0)