Azure shared image gallery is a feature that helps you to manage VM images and deploy them across the world. This service enables you to do versioning and grouping of images. Moreover, image stored in shared image gallery can be shared across subscriptions and even between Active Directory. In this topic, we will see how to leverage Azure shared image gallery.
Create a VM image
First, you need a VM image. To create this image, we need to deploy an Azure VM. To do so, open the marketplace and create an Azure VM with the operating system of your choice. In my example, I selected Windows Server 2019. As usual, fill the field with your settings such as the resource group, the VM name, region and so on.
Do not forget to specify the network configuration especially if you want to customize your image before the capture:
Once the VM is created, connect to that VM to make the customization, the updates and so on.
Once you have finished your customization you can run sysprep. Open a command prompt and run the following command:
C:\windows\system32\sysprep\sysprep.exe /oobe /shutdown /generalize /mode:VM
Now go back in the Azure Portal and open VM overview. Now you can capture your VM:
Then provide name for the image. I selected also to delete virtual machine after the image is created.
Now, you have VM image and we can integrate it into Azure shared image gallery.
Create an Azure shared image gallery
To open the service, just type shared image gallery in the search bar in Azure Portal.
Now click on Create shared image gallery.
Specify the name, the region and the resource group where belong this new shared image gallery.
Once the shared image gallery is created, you should retrieve it in the previous window:
Add image to azure shared gallery
Open the gallery and click on Add new image definition:
Then specify a region, an operating system, a VM generation the state of the OS, a publisher an offer and a SKU.
In version screen, first specify a version name. Then choose the source image that is the one we have captured previously from the Azure VM. You can specify an end of life date for the image and the target region. As you can see, you can easily distribute your VM image across Azure region.
In the next screen, you can specify publishing meta data and VM size recommendation.
It can take a while to distribute VM image across region. Once it is distributed, the image is available in the gallery.
Now you can click on Create VM button from the gallery. Then you get the same screen as usual when you want to create an Azure VM excepted in Image field. Now you can select the image from your gallery.
Conclusion
As you have seen, the deployment and configuration of Azure Shared Galleries is easy. It can help you to manage your VM images and distribute them across Azure region. Thanks to this feature, you can have streamlined VMs in Azure.