Redaguoti

Bendrinti naudojant


List, update, and delete gallery resources

You can manage your Azure Compute Gallery (formerly known as Shared Image Gallery) resources using the Azure CLI or Azure PowerShell.

List galleries shared with you

List Galleries shared with your subscription.

region=westus
az sig list-shared --location $region 

List Galleries shared with your tenant.

region=westus
az sig list-shared --location $region --shared-to tenant 

The output will contain the public name and uniqueID of the gallery that is shared with you. You can use the name of the gallery to query for images that are available through the gallery.

Here is example output:

[
  {
    "location": "westus",
    "name": "1231b567-8a99-1a2b-1a23-123456789abc-MYDIRECTSHARED",
    "uniqueId": "/SharedGalleries/1231b567-8a99-1a2b-1a23-123456789abc-MYDIRECTSHARED"
  }
]

Update resources

There are some limitations on what can be updated. The following items can be updated:

Azure Compute Gallery:

  • Description

Image definition:

  • Recommended vCPUs
  • Recommended memory
  • Description
  • End of life date

Image version:

  • Regional replica count
  • Target regions
  • Exclusion from latest
  • End of life date

Update the description of a gallery using (az sig update.

az sig update \
   --gallery-name myGallery \
   --resource-group myGalleryRG \
   --set description="My updated description."

Update the description of an image definition using az sig image-definition update.

az sig image-definition update \
   --gallery-name myGallery\
   --resource-group myGalleryRG \
   --gallery-image-definition myImageDefinition \
   --set description="My updated description."

Update an image version to add a region to replicate to using az sig image-version update. This change will take a while as the image gets replicated to the new region.

az sig image-version update \
   --resource-group myGalleryRG \
   --gallery-name myGallery \
   --gallery-image-definition myImageDefinition \
   --gallery-image-version 1.0.0 \
   --add publishingProfile.targetRegions  name=eastus

This example shows how to use az sig image-version update to exclude this image version from being used as the latest image.

az sig image-version update \
   --resource-group myGalleryRG \
   --gallery-name myGallery \
   --gallery-image-definition myImageDefinition \
   --gallery-image-version 1.0.0 \
   --set publishingProfile.excludeFromLatest=true

This example shows how to use az sig image-version update to include this image version in being considered for latest image.

az sig image-version update \
   --resource-group myGalleryRG \
   --gallery-name myGallery \
   --gallery-image-definition myImageDefinition \
   --gallery-image-version 1.0.0 \
   --set publishingProfile.excludeFromLatest=false

Delete resources

You have to delete resources in reverse order, by deleting the image version first. After you delete all of the image versions, you can delete the image definition. After you delete all image definitions, you can delete the gallery.

Before you can delete a community shared gallery, you need to use az sig share reset to stop sharing the gallery publicly.

Delete an image version using az sig image-version delete.

az sig image-version delete \
   --resource-group myGalleryRG \
   --gallery-name myGallery \
   --gallery-image-definition myImageDefinition \
   --gallery-image-version 1.0.0 

Delete an image definition using az sig image-definition delete.

az sig image-definition delete \
   --resource-group myGalleryRG \
   --gallery-name myGallery \
   --gallery-image-definition myImageDefinition

Delete a gallery using az sig delete.

az sig delete \
   --resource-group myGalleryRG \
   --gallery-name myGallery

Community galleries

Important

Azure Compute Gallery – community galleries is currently in PREVIEW and subject to the Preview Terms for Azure Compute Gallery - community gallery.

To publish a community gallery, you'll need to set up preview features in your Azure subscription. Creating VMs from community gallery images is open to all Azure users.

To list your own galleries, and output the public names for your community galleries:

az sig list --query [*]."{Name:name,PublicName:sharingProfile.communityGalleryInfo.publicNames}"

Note

As an end user, to get the public name of a community gallery, you currently need to use the portal. Go to Virtual machines > Create > Azure virtual machine > Image > See all images > Community Images > Public gallery name.

List all of the image definitions that are available in a community gallery using az sig image-definition list-community.

In this example, we list all of the images in the ContosoImage gallery in West US and by name, the unique ID that is needed to create a VM, OS and OS state.

 az sig image-definition list-community \
   --public-gallery-name "ContosoImages-1a2b3c4d-1234-abcd-1234-1a2b3c4d5e6f" \
   --location westus \
   --query [*]."{Name:name,ID:uniqueId,OS:osType,State:osState}" -o table

List image versions shared in a community gallery using az sig image-version list-community:

az sig image-version list-community \
   --location westus \
   --public-gallery-name "ContosoImages-1a2b3c4d-1234-abcd-1234-1a2b3c4d5e6f" \
   --gallery-image-definition myImageDefinition \
   --query [*]."{Name:name,UniqueId:uniqueId}" \
   -o table

Direct shared galleries

Important

Azure Compute Gallery – direct shared gallery is currently in PREVIEW and subject to the Preview Terms for Azure Compute Gallery.

To publish images to a direct shared gallery during the preview, you need to register at https://aka.ms/directsharedgallery-preview. Creating VMs from a direct shared gallery is open to all Azure users.

During the preview, you need to create a new gallery, with the property sharingProfile.permissions set to Groups. When using the CLI to create a gallery, use the --permissions groups parameter. You can't use an existing gallery, the property can't currently be updated.

To find the uniqueID of a gallery that is shared with you, use az sig list-shared. In this example, we are looking for galleries in the West US region.

region=westus
az sig list-shared --location $region --query "[].uniqueId" -o tsv

List all of the image definitions that are shared directly with you, use az sig image-definition list-shared.

In this example, we list all of the images in the gallery in West US and by name, the unique ID that is needed to create a VM, OS and OS state.

name="1a2b3c4d-1234-abcd-1234-1a2b3c4d5e6f-myDirectShared"
 az sig image-definition list-shared \
   --gallery-unique-name $name
   --location $region \
   --query [*]."{Name:name,ID:uniqueId,OS:osType,State:osState}" -o table

List image versions directly shared to you using az sig image-version list-shared:

imgDef="myImageDefinition"
az sig image-version list-shared \
   --location $region \
   --public-gallery-name $name \
   --gallery-image-definition $imgDef \
   --query [*]."{Name:name,UniqueId:uniqueId}" \
   -o table

Next steps