Azure Compute Gallery, previously known as Shared Image Gallery, is a service on Azure that provides management for VM images in Azure. It allows IT administrators to create, share, and manage custom virtual machine (VM) images in the Azure environment. These images can be used later for creating new VMs. While working towards the AZ-104 Microsoft Azure Administrator exam, one of the topics you should be fully acquainted with is how to manage images using the Azure Compute Gallery.
Creating an Image
Creating an image in the Azure Compute Gallery is a straightforward task. First, you’ll need to create a VM, then you can generalize and capture the image. Note that once you have captured an image of a VM, you can’t restart or use that VM. Therefore, you should consider creating images from VMs that you no longer need.
az sig image-version create \
--resource-group myResourceGroup \
--gallery-name myGallery \
--gallery-image-definition myImageDefinition \
--gallery-image-version 1.0.0 \
--managed-image "/subscriptions/mySubscription/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/myImage"
Image Replication
With Azure Compute Gallery, image replication across Azure regions becomes easy. You can replicate your images to different regions to enable quicker VM deployments. During the replication, you can select the regions in which you want to store your image version using the “–target-region” parameter.
az sig image-version create \
--resource-group myResourceGroup \
--gallery-name myGallery \
--gallery-image-definition myImageDefinition \
--gallery-image-version 1.0.0 \
--target-region "West Europe" "East US" \
--replica-count 1 2 \
--managed-image "/subscriptions/mySubscription/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/myImage"
Sharing VM images
What is more convenient on Azure Compute Gallery is the sharing of VM images across your organization’s subscriptions. To achieve this, you’ll need to configure RBAC (Role-Based Access Controls), where you’ll assign the reader role for accessing the gallery, image definition, and image version. Use the “–assignee” parameter to specify the user, group or application to which the role should be granted.
az role assignment create \
--assignee john.doe@mydomain.com \
--scope /subscriptions/mySubscription/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/myGallery \
--role Reader
Versioning of VM images
Azure Compute Gallery supports versioning for your VM images, which aids in the management of different updates of your VM image. You can create an image definition in your gallery and then add versions to the image definition.
az sig image-version create \
--resource-group myResourceGroup \
--gallery-name myGallery \
--gallery-image-definition myImageDefinition \
--gallery-image-version 1.0.0 \
--managed-image "/subscriptions/mySubscription/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/myImage"
In conclusion, properly managing VM images in Azure Compute Gallery will become a crucial skill as you prepare for the AZ-104 Microsoft Azure Administrator exam. By mastering this functionality, you will be significantly closer to passing your exam. Each of the steps discussed above can play a crucial part in your day-to-day administration tasks or in designing solutions on Azure. Remember, practice is crucial, so, it is advisable to create a few images in Azure Compute Gallery and manage them effectively.
Practice Test
True or False: The Azure Compute Gallery allows you to share your images to different Azure subscriptions.
- True
- False
Answer: True
Explanation: The Azure Compute Gallery supports sharing of custom VM images across different subscriptions, making it a useful tool for managing images.
What can you use to create and manage galleries in Azure Compute Gallery?
- a) Azure portal
- b) Azure CLI
- c) Azure PowerShell
- d) All of the above
Answer: d) All of the above
Explanation: All these tools – Azure portal, Azure CLI, Azure PowerShell can be used to create and manage galleries in Azure Compute Gallery.
True or False: You cannot replicate images in an Azure image gallery to multiple regions.
- True
- False
Answer: False
Explanation: Azure Compute Gallery allows you to replicate images to multiple regions. This provides more reachable, efficient, and resilient image deployment.
What is the maximum number of gallery images per subscription in Azure Compute Gallery?
- a) 100
- b) 1000
- c) 10,000
- d) No limit
Answer: b) 1000
Explanation: You can have up to 1000 gallery images per subscription in Azure Compute Gallery.
True or False: Azure Compute Gallery supports the use of both specialized and generalized images.
- True
- False
Answer: True
Explanation: Azure Compute Gallery supports the use of both specialized and generalized images, offering flexibility in managing images.
Which Azure service can be used to version control images?
- a) Azure Compute Gallery
- b) Azure DevOps
- c) Azure Functions
- d) Azure Logic Apps
Answer: a) Azure Compute Gallery
Explanation: Azure Compute Gallery allows you to version control your images, so you can keep track of their changes over time.
True or False: Azure Compute Gallery only supports Linux images.
- True
- False
Answer: False
Explanation: Azure Compute Gallery supports both Linux and Windows images.
What is the level of access your subscription needs to offer to use Shared Image Gallery?
- a) Reader
- b) Owner
- c) Contributor
- d) All of the above
Answer: a) Reader
Explanation: At the minimum, your subscription needs to have Reader access to use Shared Image Gallery.
True or False: Azure Compute Gallery allows creating images from both Managed Disks and VHDs.
- True
- False
Answer: True
Explanation: Azure Compute Gallery supports creation of images from both Managed Disks and VHDs.
Which Azure resource can be used to share VM Images across different Azure Subscriptions and Regions?
- a) Azure Shared Disk
- b) Azure Shared Image Gallery
- c) Azure Disk Storage
- d) Azure Blob Storage
Answer: b) Azure Shared Image Gallery
Explanation: Azure Shared Image Gallery is a service that allows you to share your VM images across different Azure subscriptions and to different Regions.
True or False: In the Azure Compute Gallery, each VM version must belong to an image definition.
- True
- False
Answer: True
Explanation: This is true. Each VM version must belong to an image definition in Azure Compute Gallery as a way of organizing and managing VM images.
What types of versions are supported by Azure Compute Gallery?
- a) Major
- b) Minor
- c) Patch
- d) All of the above
Answer: d) All of the above
Explanation: Azure Compute Gallery supports Major, Minor and Patch types of versions for maintaining image versions.
True or False: You cannot use Managed Disks with Azure Compute Gallery.
- True
- False
Answer: False
Explanation: Azure Compute Gallery supports both Managed Disks and unmanaged disks.
Can images be replicated to more than one region in Azure Compute Gallery?
- a) Yes
- b) No
Answer: a) Yes
Explanation: Images can be replicated to multiple regions for more efficient and resilient deployment using Azure Compute Gallery.
How can an Azure user manage the lifecycle of images in Azure Compute Gallery?
- a) Azure Automation
- b) Azure Policies
- c) Both
- d) None of them
Answer: c) Both
Explanation: Azure user can manage the lifecycle of images with Azure Automation and Azure Policies in Azure Compute Gallery.
Interview Questions
1. What is Azure Compute Gallery?
Azure Compute Gallery (Shared Image Gallery) is a service that helps you to build structure and distribution of the custom virtual hard disks (VHDs), templates, and more.
2. How many images can a Shared Image Gallery have?
A Shared Image Gallery can contain multiple image definitions, and each image definition can have multiple named versions of an image.
3. What are the three components of the Shared Image Gallery?
The three components of the Shared Image Gallery are the Shared Image Gallery itself, Image Definition, and Image Versions.
4. What is the purpose of Image Definition in Azure Compute Gallery?
Image Definition in Azure Compute Gallery is used to group versions of an image. Image definitions carry information about the image and requirements for using it like OS type, recommended VM size, and more.
5. What does the Image Version contain in Azure Compute Gallery?
Image Version contains an image and manages the distribution of an image. You can have multiple versions of an image per Image Definition.
6. Can you replicate Image Versions across multiple Azure regions?
Yes, you can replicate Image Versions across multiple Azure regions, and you can specify how many replicas you want in each region.
7. What can be the maximum number of replicas of an image version in a region?
The maximum number of replicas of an image version in a region is 10.
8. Can you use PowerShell to manage images in Azure Compute Gallery?
Yes, you can use PowerShell, Azure CLI, or SDKs to manage images in Azure Compute Gallery alongside the Azure portal.
9. How to create a Shared Image Gallery in Azure?
A Shared Image Gallery can be created using the Azure portal, Azure Powershell, Azure CLI, or SDKs. This process involves creating a resource group if it doesn’t already exist, and then using the appropriate commands or instructions to create the gallery.
10. Can you share a Shared Image Gallery with other subscriptions?
Yes, you can share a Shared Image Gallery with other subscriptions by assigning the appropriate role access at the Image Definition level.
11. What’s the minimum and maximum number of versions allowed per image in Shared Image Gallery?
In Shared Image Gallery, the minimum number of versions per image is 1, and the maximum number is 1,000.
12. How can you distribute images to the Azure Government cloud or China regions?
To distribute images to Azure Government cloud or China regions, your shared Image must be created within that cloud.
13. What is the use of a replication count in Azure Compute Gallery?
The replication count signifies the number of copies of an image. A higher number of replicas helps in faster allocation of VM during deployment since Azure doesn’t need to copy the image before deploying the VM.
14. Can you update an existing image version in Shared Image Gallery?
No, you cannot update an existing image version in Shared Image Gallery. However, you can create a new image version with the updated content.
15. Can I move Shared Image Gallery, image definition, and image version resources across different resource groups or subscriptions?
Yes, you can move Shared Image Gallery, image definition, and image version resources across different resource groups or subscriptions.