Azure Compute Gallery is a service in Microsoft Azure that allows you to create, manage, and share custom virtual machine (VM) images with ease. This write-up will guide you through the process of creating an Azure Compute Gallery step by step.
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.
Virtual Machine: An existing Azure virtual machine that you want to capture an image from.
Step 1: Create a Gallery
- Log in to the Azure Portal.
In the left-hand menu, click on Create a resource.
- In the search bar, type "Compute Gallery" and select it from the search results.
- Click the Create button.
- Fill in the required details:
- Subscription: Select your Azure subscription.
- Resource group: Choose the resource group you created earlier.
- Gallery name: Choose a unique name for your gallery.
- Region: Choose the Azure region where you want to deploy the gallery.
- Click the 'Next + Sharing method' button.
- Sharing method: On the sharing method page, leave it on default which is the Role based access control(RBAC). Role-Based Access Control (RBAC) in Azure is a security mechanism that regulates access to resources. It employs roles with specific permissions, which are assigned to users, groups, or applications through role assignments. RBAC functions across various levels like management groups, subscriptions, resource groups, and resources themselves. It prioritizes least privilege and can be managed through the Azure Portal, PowerShell, CLI, or templates. Regular audits are important for maintaining security and compliance.
- Click the 'Next: Tag' button.
Leave the Tags on default or you can create a Tag or you can assign tags based on your preference. Click the Review + create button to review your settings. Make sure everything is configured correctly.
- Finally, click the Create button to create the gallery once validation is passed.
Once your deployment is completed, you have successfully created an Azure Compute Gallery. Click on the 'Go to resource' button to access your newly deployed compute gallery.
Step 2: Capturing an Azure Virtual Machine Image to Compute Gallery
Prepare the Virtual Machine
Before capturing the VM image, ensure that your VM is in a suitable state:
Stop the VM: It's recommended to stop the VM to ensure a consistent state during the capture process. You can stop it from the Azure Portal.
Deallocate the VM: If you are capturing an image from a VM that is not in a deallocated state, you can deallocate it from the Azure Portal to avoid additional charges. Azure deallocates VM automatically during this process if you don't do it manually.
Step 3: Capture the VM Image
In the Azure Portal, navigate to the Virtual machines section.
Select the VM you want to capture an image from.
In the VM's overview page, under Settings, click on Capture. This action initiates the image capture process.
Provide the required information:
- Image target gallery: Select the Azure Compute Gallery where you want to store this image.
- Operating system state: choose one out of the two option Generalized and Specialized, In the context of Azure Virtual Machine (VM) image capture, "Generalized" and "Specialized" refer to two different states of the VM:
Generalized: When a VM is in a "Generalized" state, it has been prepared to be a reusable image. In this state, any specific configuration and unique information, such as the computer name, have been removed or generalized. This process typically involves running the "Sysprep" tool on a Windows VM or executing similar steps on a Linux VM. After this, the VM is often shut down. Generalized VMs are suitable for creating custom images that can be used to deploy multiple VM instances with the same base configuration.
Specialized: A VM in a "Specialized" state is one that hasn't undergone the generalization process. It's in a specific, unique configuration with potentially personalized settings and data. Specialized VMs are typically used for ongoing production purposes and are not intended to be used as a template for creating new VM instances.
When capturing an image of an Azure VM, it's essential to generalize the VM first if you want to create a reusable image. Specialized VMs, on the other hand, are kept as-is for ongoing operations. Understanding and appropriately managing the state of your VMs is crucial for efficient image management in Azure. Here we picked Specialized since we are having an ongoing operation and want to have the ease of not authenticating when we scale.
- Target VM image definition: Click on 'Create New'.
- VM Image definition name: Choose a unique name for your captured image. Leave other fields as default and click 'Ok'.
- Image version: Provide a version number and an optional description for this image version. Versioning in VM image capture is the practice of maintaining multiple snapshots or versions of a virtual machine image in Azure. Instead of overwriting the original image, each change or update creates a new version. This allows for flexible deployment, enabling you to choose specific image versions when creating VM instances. It's essential for managing changes and ensuring the ability to revert to known, stable configurations when needed.
- Replication: This refers to the process of duplicating the VM's virtual hard disk (VHD) to create a copy of the VM's entire state, including the operating system, installed software, and data. Here we are replicating just 1 image of our VM and our storage option is Zone Redundant. Configure the target region(s) where this image version will be available.
- Click 'Review + create' to review your settings. Ensure that everything is configured correctly.
- Finally, click 'Create' to start the image capture process. The VM will be deallocated, and Azure will capture an image of it.
Once the process is complete, the captured image will be stored in your specified Azure Compute Gallery. Once deployment is complete you can now 'Go to resource'.
Tadaa! πThis is our captured VM Image in our compute gallery.
Conclusion
You've successfully captured an image from an Azure virtual machine and stored it in an Azure Compute Gallery. This process allows you to maintain a library of custom VM images, making it easier to provision standardized virtual machines for your Azure deployments. Remember to update your gallery with new versions as your VM images evolve over time.
Top comments (0)