Mastering your Azure Virtual Machine: Creating a Compute Gallery and VM Image from an Existing VM

Lawal AzeezLawal Azeez
4 min read

The Azure Compute Gallery lets you manage, and share custom VM images and application packages with others in your organization, within or across regions. It helps you build structure and organization around your Azure resources, like images and applications across the board. We will be looking at how to create a Compute gallery from an existing virtual machine.

Prerequisite

Before we start, kindly ensure you have your VM (Linux or Windows) ready. If you don't kindly check one of my write-ups on Creating a Linux Virtual Machine or Windows 10 virtual machine.

Let's begin...

Go to your Azure portal, log in to your Azure subscription and ensure you are on the Azure portal homepage.

From the general search bar above, type "compute gallery" and select "Azure compute galleries" from the search results

From the Azure compute gallery homepage, click on "Create" to start creating your image.

Enter all the information highlighted in the image below.

Subscription: Select your subscription. Resource group: Select or Create a new resource group. Name: Give your compute gallery a suitable name. Region: Select your preferred region. Description: Describe your image gallery for future identification and reference

Click "Next: Sharing method"

Leave sharing method at RBAC (Role-based access control).

Click "Next: Tags" to tag your image.

Click "Next: Review + create". Allow validation to pass.

Click "create"

Your Compute image gallery looks like this.

Go to your Virtual machine homepage. Ensure that your VM is stopped and deallocated by clicking the "Stop" and "Yes" on the VM homepage.

Once your VM is stopped, click "Capture" on your VM (just beside the stop button) to begin the capture process.

From the image below, you will notice that some parameters have been filled out for you like your resource group (unless you want to change it but you cannot create), and your Region (Compute gallery image is regional scoped service). Now ensure your option is set to "yes, share it to a gallery as a VM image version". You can choose to delete the VM after capturing but I choose to leave mine as it is (capturing a virtual machine will make the VM unusable but the image can be used to replicate several VMs as we intend to do in the future). Select your Target Azure compute gallery as the one we recently created above.

Scroll down and select your Operating system state as "Specialized". The general operating system state puts you through the hassle of having to enter a hostname, username and password every time you want to make use of the setup, which is not ideal for a large regional organization with lots of IT administrators. I strongly recommend using the specialized option for ease of use in deployments

Create your Target VM definitions. This means that you define what you want to use the parent image for, some can be used as a template for all VMs deployment while some can be used for VMSS (Virtual Machine Scale Set) as in this case. Click on Create, and give it a Name, you will notice your image is selected for the OS you want to deploy, go ahead and click OK.

Skip the "End of life date" except if you only want to retain it for some time then you can adjust the date.

Replication: A VM image version can be replicated to different regions depending on what makes sense for your organization. One example is to always replicate the latest image in multiple regions while all older versions are only available in 1 region. This can help save on storage costs for VM image versions.

Click "Review + Create"

Once validation is passed, click "Create"

Your Compute Image Dashboard

In Conclusion, Azure compute image gallery is a very useful resource for storing your deployment template to ensure compliance and best practices in deploying similar instances of a VM across the organization. It can also be kept for future use to either spin up more VM instances or repair existing faulty VMs in case of any issue.

I hope this has been informative for you and I would like to thank you for reading.

0
Subscribe to my newsletter

Read articles from Lawal Azeez directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Lawal Azeez
Lawal Azeez

I am a cloud administrator, simply documenting my cloud computing journey.