Create an Azure Compute Gallery using the portal

Applies to: ✔️ Linux VMs ✔️ Flexible scale sets Applies to: ✔️ ✔️ Uniform scale sets

An Azure Compute Gallery simplifies custom image sharing across your organization. Custom images are like marketplace images, but you create them yourself. Custom images can be used to bootstrap deployment tasks like preloading applications, application configurations, and other OS configurations.

The Azure Compute Gallery lets you share your custom VM images with others in your organization, within or across regions, within an Azure AD tenant. Choose which images you want to share, which regions you want to make them available in, and who you want to share them with. You can create multiple galleries so that you can logically group images.

The gallery is a top-level resource that provides full Azure role-based access control (Azure RBAC). Images can be versioned, and you can choose to replicate each image version to a different set of Azure regions. The gallery only works with Managed Images.

The Azure Compute Gallery feature has multiple resource types. We will be using or building these in this article:

Resource Description
Image source This is a resource that can be used to create an image version in a gallery. An image source can be an existing Azure VM that is either generalized or specialized, a managed image, a snapshot, or an image version in another gallery.
Gallery Like the Azure Marketplace, a gallery is a repository for managing and sharing images and VM applications, but you control who has access.
Image definition Image definitions are created within a gallery and carry information about the image and requirements for using it internally. This includes whether the image is Windows or Linux, release notes, and minimum and maximum memory requirements. It is a definition of a type of image.
Image version An image version is what you use to create a VM when using a gallery. You can have multiple versions of an image as needed for your environment. Like a managed image, when you use an image version to create a VM, the image version is used to create new disks for the VM. Image versions can be used multiple times.

Before you begin

To complete the example in this article, you must have an existing managed image of a generalized VM, or a snapshot of a specialized VM. You can follow Tutorial: Create a custom image of an Azure VM with Azure PowerShell to create a managed image, or Create a snapshot for a specialized VM. For both managed images and snapshots, the data disk size cannot be more than 1 TB.

When working through this article, replace the resource group and VM names where needed.

An image gallery is the primary resource used for enabling image sharing. Allowed characters for Gallery name are uppercase or lowercase letters, digits, dots, and periods. The gallery name cannot contain dashes. Gallery names must be unique within your subscription.

The following example creates a gallery named myGallery in the myGalleryRG resource group.

  1. Sign in to the Azure portal at https://portal.azure.com.
  2. Use the type Shared image gallery in the search box and select Shared image gallery in the results.
  3. In the Shared image gallery page, click Add.
  4. On the Create shared image gallery page, select the correct subscription.
  5. In Resource group, select Create new and type myGalleryRG for the name.
  6. In Name, type myGallery for the name of the gallery.
  7. Leave the default for Region.
  8. You can type a short description of the gallery, like My image gallery for testing. and then click Review + create.
  9. After validation passes, select Create.
  10. When the deployment is finished, select Go to resource.

Create an image definition

Image definitions create a logical grouping for images. They are used to manage information about the image versions that are created within them.

Image definition names can be made up of uppercase or lowercase letters, digits, dots, dashes and periods. For more information about the values you can specify for an image definition, see Image definitions.

Create the gallery image definition inside of your gallery.

  1. On the page for your new image gallery, select Add a new image definition from the top of the page.
  2. In the Add new image definition to shared image gallery, for Region, select East US.
  3. For Image definition name, type a name like myImageDefinition.
  4. For Operating system, select the correct option based on your source VM.
  5. For VM generation, select the option based on your source VM. In most cases, this will be Gen 1. For more information, see Support for generation 2 VMs.
  6. For Operating system state, select the option based on your source VM. For more information, see Generalized and specialized.
  7. For Publisher, type myPublisher.
  8. For Offer, type myOffer.
  9. For SKU, type mySKU.
  10. When finished, select Review + create.
  11. After the image definition passes validation, select Create.
  12. When the deployment is finished, select Go to resource.

Create an image version

When choosing target regions for replication, remember that you also have to include the source region as a target for replication.

The steps for creating an image version are slightly different, depending on whether the source is a generalized image or a snapshot of a specialized VM.

  1. In the page for your image definition, select Add version from the top of the page.

  2. In Region, select the region where you want the image created.

  3. For Version number, type a number like 1.0.0. The image version name should follow major.minor.patch format using integers.

  4. In Source image, select your source managed image from the drop-down. See the table below for specific details for each source type.

    Source Other fields
    Disks or snapshots - For OS disk select the disk or snapshot from the drop-down.
    - To add a data disk, type the LUN number and then select the data disk from the drop-down.
    Image version - Select the Source gallery from the drop-down.
    - Select the correct image definition from the drop-down.
    - Select the existing image version that you want to use from the drop-down.
    Managed image Select the Source image from the drop-down.
    The managed image must be in the same region that you chose in Instance details.
    VHD in a storage account Select Browse to choose the storage account for the VHD.
  5. In Exclude from latest, leave the default value of No.

  6. For End of life date, select a date from the calendar that is a couple of months in the future.

  7. In the Replication tab, select the storage type from the drop-down.

  8. Set the Default replica count, you can override this for each region you add.

  9. You need to replicate to the source region, so the first replica in the list will be in the region where you created the image. You can add more replicas by select the region from the drop-down and adjusting the replica count as necessary.

  10. When you are done, select Review + create. Azure will validate the configuration.

  11. When image version passes validation, select Create.

  12. When the deployment is finished, select Go to resource.

It can take a while to replicate the image to all of the target regions.

You can also capture an existing VM as an image, from the portal. For more information, see Create an image of a VM in the portal.

We recommend that you share access at the image gallery level. The following walks you through sharing the gallery that you just created.

  1. On the page for your new image gallery, in the menu on the left, select Access control (IAM).
  2. Under Add a role assignment, select Add. The Add a role assignment pane will open.
  3. Under Role, select Reader.
  4. Under assign access to, leave the default of Azure AD user, group, or service principal.
  5. Under Select, type in the email address of the person that you would like to invite.
  6. If the user is outside of your organization, you will see the message This user will be sent an email that enables them to collaborate with Microsoft. Select the user with the email address and then click Save.

If the user is outside of your organization, they will get an email invitation to join the organization. The user needs to accept the invitation, then they will be able to see the gallery and all of the image definitions and versions in their list of resources.

Create VMs

Now you can create one or more new VMs. This example creates a VM named myVMfromImage, in the myResourceGroup in the East US datacenter.

  1. Go to your image definition. You can use the resource filter to show all image definitions available.
  2. On the page for your image definition, select Create VM from the menu at the top of the page.
  3. For Resource group, select Create new and type myResourceGroup for the name.
  4. In Virtual machine name, type myVM.
  5. For Region, select East US.
  6. For Availability options, leave the default of No infrastructure redundancy required.
  7. The value for Image is automatically filled with the latest image version if you started from the page for the image definition.
  8. For Size, choose a VM size from the list of available sizes and then choose Select.
  9. Under Administrator account, if the source VM was generalized, enter your Username and SSH public key. If the source VM was specialized, these options will be greyed out because the information from the source VM is used.
  10. If you want to allow remote access to the VM, under Public inbound ports, choose Allow selected ports and then select SSH (22) from the drop-down. If you don't want to allow remote access to the VM, leave None selected for Public inbound ports.
  11. Select Other under Licensing, unless your image is based on RedHat or SLES.
  12. When you are finished, select the Review + create button at the bottom of the page.
  13. After the VM passes validation, select Create at the bottom of the page to start the deployment.

Clean up resources

When no longer needed, you can delete the resource group, virtual machine, and all related resources. To do so, select the resource group for the virtual machine, select Delete, then confirm the name of the resource group to delete.

If you want to delete individual resources, you need to delete them in reverse order. For example, to delete an image definition, you need to delete all of the image versions created from that image.

Next steps

You can also create Azure Compute Gallery resource using templates. There are several Azure Quickstart Templates available:

For more information about Azure Compute Galleries, see the Overview. If you run into issues, see Troubleshooting galleries.