DEV Community

Cover image for Custom VM Image Creation and Deployment Using Azure Compute Gallery and Virtual Machine Scale Sets
Oluwanifesimi
Oluwanifesimi

Posted on

Custom VM Image Creation and Deployment Using Azure Compute Gallery and Virtual Machine Scale Sets

Introduction

This will guide you through the steps to build a reusable image from an Azure Virtual Machine (VM) and save it in an Azure Compute Gallery (previously called Shared Image Gallery). By doing this, you can replicate VM setups and launch multiple identical VMs quickly and consistently.

Here's what we'll cover:

  • Setting up an Azure Compute Gallery
  • Capturing a VM image from an existing virtual machine
  • Uploading and storing the image in the gallery
  • Using the custom image to deploy a Virtual Machine Scale Set (VMSS)

Step 1:Setting up an Azure Compute Gallery
An Azure Compute Gallery (formerly Shared Image Gallery) image is a managed resource that stores and organizes custom VM images in Azure

  • In the search bar, type "Azure Compute Galleries" and select it
    search azure compute

  • Click + Create
    Azure create

  • Fill in the details:

  • Subscription: Select your subscription

  • Resource group: Select existing or create new

  • Name: Enter a name (e.g., "AlphaGallery")

  • Region: Select a region (e.g., West US)

  • Click Review + create,
    Azure fill in details

  • Then Create
    create

  • Click on go to resources to see the created gallery.
    go to resource

  • Compute Gallery is created successfully (AlphaGallery)
    Gallery created

Step 2: Create a VM Image from an Existing VM
Creating a vm image means you want to create a replica of the original image with the same configuration and settings.

  • In the search bar, type "Virtual Machine" and select it
    vm

  • Select the existing Virtual Machine
    existing

  • click Capture drop down and select image.
    capture

  • In the "Create image" blade:

  • Select resource group (AlphaRG)

  • Choose Operating system state (I picked specialised because i dont want the users of the image to login into the vm with any credentials) Generalised requires Login Access.

  • Create new Target Vm image definition
    generate image

  • Give the target vm image definition a name (AlphaImageDefinition)

  • Click OK
    name image

  • set version number to 0.0.1

  • Click Create + review
    create + Re

  • Click create
    select Create image

  • Click go to resources to see your image
    resource image

Step 3: Deploy a VM Scale Set from the Custom Image
A Virtual Machine Scale Set (VMSS) is an Azure service that allows the automatic deployment and scaling of identical VMs based on demand.

  • In the search bar, type "Azure Compute Galleries" and select it
    search azure compp

  • Select your gallery (AlphaGallery)
    Gallery

  • Select your image (AlphaImageDefinition)
    AlphaImage

  • Click on + Create VMSS to create a virtual machine scale set.
    create mss

  • Select resource group (NK_RG)

  • Give your Virtual Machine scale set a name (Alphascaleset)

  • Select availability zone (zone 1)

  • Ocherstration mode is set to uniform
    ochestration

  • Scaling mode is set to manual

  • Instant count is set to 3 (set based on your preference

  • Select AlphaImageDefinition for the image
    scaleset setting

  • The administration account is grade-out because we select specialised mode when creating the image.

  • Click review + create
    reiew + CREATE

  • Click Create
    create ssss

  • Click on go to resources to view your deployed virtual machine scale set
    gt resource

  • Three instance of Virtual machine scale set as been created succesfully

  • Click on status to view the Three vmss
    click status

3 cmss

Conclusion
This project successfully demonstrated the creation of a reusable image from an Azure Virtual Machine and its integration into an Azure Compute Gallery. The image was then deployed through a Virtual Machine Scale Set, enabling consistent replication of VM configurations across multiple instances. This approach enhances scalability, simplifies infrastructure management, and ensures uniformity in deployment environments. The outcome validates the effectiveness of Azure Compute Gallery in streamlining VM provisioning for enterprise-grade solutions.

Top comments (0)