az-image
Manage virtual machine images in Azure
TLDR
List the custom images under a resource group
Create a custom image from managed disks or snapshots
Delete a custom image
Show details of a custom image
Update custom images
SYNOPSIS
az image subcommand [options]
Example: az image create --resource-group myResourceGroup --name myCustomImage --source mySourceVM
Example: az image list --output table
PARAMETERS
--resource-group | -g name
Name of the Azure resource group. Determines the scope for image creation and management.
--name | -n name
The name of the custom image being created, shown, or deleted.
--source id | name | URL
The source from which to create the image. Can be a VM name, VM ID, disk ID, snapshot ID, or blob URI.
--location | -l location
Location in which to create the image (e.g., 'eastus', 'westus2'). Defaults to the resource group's location.
--os-type type
The operating system type of the image (e.g., 'Linux', 'Windows').
--hyper-v-generation generation
The Hyper-V generation of the image (e.g., 'V1', 'V2').
--gallery-name name
Name of the Azure Compute Gallery to store the image in.
--gallery-image-definition name
Name of the gallery image definition, required when using a gallery.
--tags key=value key=value
Space-separated tags in 'key[=value]' format to apply to the image resource.
--subscription id
The ID or name of the Azure subscription to use. Overrides the default or configured subscription.
--output | -o format
Output format (e.g., 'json', 'jsonc', 'table', 'tsv', 'yaml', 'none').
--query jmespath
JMESPath query string. See http://jmespath.org/ for more information and examples.
--help | -h
Show help message for the command or subcommand.
DESCRIPTION
The command az-image is not a standalone Linux command. Instead, it is commonly used as a shorthand reference to the az image command group within the Azure Command-Line Interface (Azure CLI).
The az image command group is primarily designed for managing custom virtual machine (VM) images within Microsoft Azure. These images serve as templates for creating multiple VMs with identical configurations, significantly streamlining deployments and ensuring consistency. It supports operations such as creating new images from existing VMs, snapshots, or managed disks; deleting unwanted images; listing available images; and viewing detailed information about specific images. This functionality is crucial for infrastructure-as-code practices, DevOps workflows, and maintaining standardized environments across an organization's Azure infrastructure.
The az image commands also interact seamlessly with Azure Compute Galleries (formerly Shared Image Galleries), enabling centralized management and sharing of custom images across different subscriptions, regions, and tenants.
CAVEATS
The command 'az-image' is not a standalone executable. It refers to the 'az image' command group within the Azure CLI. Therefore, its functionality is dependent on the Azure CLI being installed and properly configured (e.g., logged in to an Azure account with appropriate permissions).
When creating a custom image from a VM for multi-instance deployment, the source VM must be generalized first (e.g., using Sysprep on Windows or waagent -deprovision+user on Linux) to remove machine-specific identifiers. Failure to do so can lead to deployment issues.
IMAGE TYPES DISTINCTION
It's important to distinguish between custom images (managed by `az image`) and marketplace images (managed by `az vm image`). Custom images are user-defined templates, often derived from existing VMs, used for tailored deployments. Marketplace images are pre-built, generalized images provided by Microsoft or third-party vendors, available for direct use from the Azure Marketplace.
GENERALIZATION REQUIREMENT
For a custom image to be reusable for creating multiple identical virtual machines, the source VM must be generalized before the image is captured. Generalization removes unique machine-specific information (like SIDs on Windows or SSH host keys on Linux) to prevent conflicts when deploying new VMs from the same image. If a VM is not generalized, the image can only be used to create an exact replica of the original VM, not a new, independent instance.
AZURE COMPUTE GALLERY (ACG) INTEGRATION
The `az image` command group strongly integrates with Azure Compute Gallery (ACG). ACG provides a structured way to manage, share, and distribute custom images. It allows for versioning of images, replicating images to different Azure regions, and sharing them with other Azure subscriptions or tenants. Using `az image` with an ACG is the recommended practice for professional image management in Azure.
HISTORY
The Azure CLI, providing the `az image` command group, has undergone continuous development since its initial releases. Earlier versions of Azure CLI offered similar capabilities for creating and managing custom VM images. A significant enhancement came with the introduction of Shared Image Galleries (later renamed to Azure Compute Galleries). This feature greatly improved the way images are managed, versioned, and shared across different subscriptions and regions, making the `az image` command group even more powerful and integral to enterprise-scale deployments. Its evolution reflects Azure's commitment to enabling robust and automated infrastructure management through command-line tools.
SEE ALSO
az(1): The main Azure CLI command for managing Azure resources., az vm(1): Commands for managing Azure virtual machines, including creation from images., az vm image(1): Used for listing and showing details of marketplace VM images., az disk(1): Commands for managing Azure managed disks, which can serve as sources for custom images.