Edit

Share via


Manage Azure Local VM Images via CLI or Portal

Applies to: Hyperconverged deployments of Azure Local

This article describes how to manage virtual machine (VM) images on your Azure Local instance. You can create VM images from various sources like Azure Marketplace, Azure Compute Gallery, Azure Storage accounts, or local shares. After you create images, you can list, view properties, and delete them using Azure CLI or the Azure portal.

Prerequisites

Before you begin, make sure you have:

List VM images

To identify which images on your Azure Local instance are available for VM management, you can view the complete list of VM images.

To list VM image using Azure CLI, follow these steps:

  1. Run PowerShell as an administrator.

  2. Set some parameters. For example, subscription and resource group:

    $subscription = "<Subscription ID associated with your Azure Local>"
    $resource_group = "<Resource group name for your Azure Local>"
    
  3. List all the VM images associated with your Azure Local. Run the following command:

    az stack-hci-vm image list --subscription $subscription --resource-group $resource_group
    

The command returns different sets of images depending on the parameters you specify:

  • Subscription only: Lists all images in the subscription

  • Subscription and resource group: Lists all images in the specific resource group

The results include VM images from:

  • VM images from marketplace images.
  • Custom images that reside in:
    • Your Azure Storage account
    • A local share on your system
    • A client connected to your system

Here's a sample output:

PS C:\Users\azcli> az stack-hci-vm image list --subscription "<Subscription ID>" --resource-group "<Resource group>"
Command group 'stack-hci-vm' is experimental and under development. Reference and support levels: https://aka.ms/CLI_refstatus
[
  {
    "extendedLocation": {
      "name": "/subscriptions/<subscription ID>/resourcegroups/<resource group>/providers/microsoft.extendedlocation/customlocations/<custom location>",
      "type": "CustomLocation"
    },
    "id": "/subscriptions/<subscription ID>/resourceGroups/<resource group>/providers/microsoft.azurestackhci/marketplacegalleryimages/w
inServer2022Az-01",
    "location": "eastus",
    "name": "winServer2022Az-01",
    "properties": {
      "hyperVGeneration": "V2",
      "identifier": {
        "offer": "windowsserver",
        "publisher": "microsoftwindowsserver",
        "sku": "2022-datacenter-azure-edition-core"
      },
      "imagePath": null,
      "osType": "Windows",
      "provisioningState": "Succeeded",
      "status": {
        "downloadStatus": {
          "downloadSizeInMB": 6710
        },
        "progressPercentage": 100,
        "provisioningStatus": {
          "operationId": "<operation ID>",
          "status": "Succeeded"
        }
      },
      "storagepathId": null,
      "version": {
        "name": "20348.2031.231006",
        "properties": {
          "storageProfile": {
            "osDiskImage": {
              "sizeInMB": 130050
            }
          }
        }
      }
    },
    "resourceGroup": "mylocal-rg",
    "systemData": {
      "createdAt": "2023-10-30T21:44:53.020512+00:00",
      "createdBy": "guspinto@contoso.com",
      "createdByType": "User",
      "lastModifiedAt": "2023-10-30T22:08:25.495995+00:00",
      "lastModifiedBy": "bbbbbbbb-1111-2222-3333-cccccccccccc",
      "lastModifiedByType": "Application"
    },
    "tags": {},
    "type": "microsoft.azurestackhci/marketplacegalleryimages"
  }
]

For more information on this CLI command, see az stack-hci-vm image list.

View VM image properties

Review detailed properties of a VM image before using it to create virtual machines.

To view image properties using Azure CLI, follow these steps:

  1. Run PowerShell as an administrator.

  2. Set the following parameters.

    $subscription = "<Subscription ID>"
    $resource_group = "<Azure Local resource group>"
    $mktplaceImage = "<Marketplace image name>"
    
  3. View image properties using one of two methods: marketplace image ID or name and resource group

    • Method 1: Using marketplace image ID

      Set the image ID parameter:

      $mktplaceImageID = "/subscriptions/<subscription ID>/resourceGroups/<resource group>/providers/Microsoft.AzureStackHCI/galleryimages/mylocal-marketplaceimage"
      

      Run the command:

      az stack-hci-vm image show --ids $mktplaceImageID
      

      Here's a sample output:

      PS C:\Users\azcli> az stack-hci-vm image show --ids $mktplaceImageID
      Command group 'stack-hci-vm' is experimental and under development. Reference and support levels: https://aka.ms/CLI_refstatus
      {
        "extendedLocation": {
          "name": "/subscriptions/<subscription ID>/resourcegroups/<resource group>/providers/microsoft.extendedlocation/customlocations/<custom location>",
          "type": "CustomLocation"
        },
        "id": "/subscriptions/<subscription ID>/resourceGroups/<resource group>/providers/Microsoft.AzureStackHCI/galleryimages/mylocal-marketplaceimage",
        "location": "eastus",
        "name": "mylocal-marketplaceimage",
        "properties": {
          "containerName": null,
          "hyperVGeneration": null,
          "identifier": null,
          "imagePath": null,
          "osType": "Windows",
          "provisioningState": "Succeeded",
          "status": null,
          "version": null
        },
        "resourceGroup": "mylocal-rg",
        "systemData": {
          "createdAt": "2022-08-05T20:52:38.579764+00:00",
          "createdBy": "guspinto@microsoft.com",
          "createdByType": "User",
          "lastModifiedAt": "2022-08-05T20:52:38.579764+00:00",
          "lastModifiedBy": "guspinto@microsoft.com",
          "lastModifiedByType": "User"
        },
        "tags": null,
        "type": "microsoft.azurestackhci/galleryimages"
      }
      
    • Method 2: Using name and resource group

      Run the command:

      az stack-hci-vm image show --name $mktplaceImage --resource-group $resource_group
      

      Here's a sample output:

      PS /home/user> az stack-hci-vm image show --name "2022-datacenter-azure-edition-hotpatch-01" --resource-group ""  
      {
        "extendedLocation": {
          "name": "/subscriptions/<subscription>/resourcegroups/<resource group>/providers/microsoft.extendedlocation/customlocations/<custom location>",
          "type": "CustomLocation"
        },
        "id": "/subscriptions/<subscription>/resourceGroups/<resource group>/providers/microsoft.azurestackhci/marketplacegalleryimages/2022-datacenter-azure-edition-hotpatch-01",
        "location": "eastus",
        "name": "2022-datacenter-azure-edition-hotpatch-01",
        "properties": {
          "cloudInitDataSource": null,
          "containerId": "/subscriptions/<subscription>/resourceGroups/<resource group>/providers/Microsoft.AzureStackHCI/storageContainers/<container name>",
          "hyperVGeneration": "V2",
          "identifier": {
            "offer": "windowsserver",
            "publisher": "microsoftwindowsserver",
            "sku": "2022-datacenter-azure-edition-hotpatch"
          },
          "osType": "Windows",
          "provisioningState": "Succeeded",
          "status": {
            "downloadStatus": {
              "downloadSizeInMb": 11424
            },
            "errorCode": "",
            "errorMessage": "",
            "progressPercentage": 100,
            "provisioningStatus": {
              "operationId": "<operation ID>",
              "status": "Succeeded"
            }
          },
          "version": {
            "name": "20348.3561.250409",
            "properties": {
              "storageProfile": {
                "osDiskImage": {
                  "sizeInMb": 130050
                }
              }
            }
          }
        },
        "resourceGroup": "<Resource group>",
        "systemData": {
          "createdAt": "2025-04-28T19:04:53.484650+00:00",
          "createdBy": "Michael.Godfrey@adaptivecloudlab.com",
          "createdByType": "User",
          "lastModifiedAt": "2025-11-25T17:00:29.308006+00:00",
          "lastModifiedBy": "dddddddd-3333-4444-5555-eeeeeeeeeeee",
          "lastModifiedByType": "Application"
        },
        "tags": {},
        "type": "microsoft.azurestackhci/marketplacegalleryimages"
      }
      

Delete VM image

Remove VM images that are no longer needed or if the download failed during creation.

To delete a VM image using Azure CLI, follow these steps:

  1. Run PowerShell as an administrator.

  2. Set the following parameters:

    $subscription = "<Subscription ID>"
    $resource_group = "<Azure Local resource group>"
    $mktplaceImage = "<Markeplace image name>"
    
  3. Remove an existing VM image. Run the following command:

    az stack-hci-vm image delete --subscription $subscription --resource-group $resource_group --name $mktplaceImage --yes
    

You can delete images using either:

  • Name and resource group
  • Image ID

After you delete an image, you can check that the image is removed.

Here's a sample output showing deletion by name and resource group:

PS C:\Users\azcli> $subscription = "<Subscription ID>"
PS C:\Users\azcli> $resource_group = "<Resource group>"
PS C:\Users\azcli> $mktplaceImage = "mymylocal-marketplaceimage"
PS C:\Users\azcli> az stack-hci-vm image delete --name $mktplaceImage --resource-group $resource_group
    
Are you sure you want to perform this operation? (y/n): y
PS C:\Users\azcli> az stack-hci-vm image show --name $mktplaceImage --resource-group $resource_group
    
ResourceNotFound: The Resource 'Microsoft.AzureStackHCI/marketplacegalleryimages/myhci-marketplaceimage' under resource group '<resource group>' was not found. For more details please go to https://aka.ms/ARMResourceNotFoundFix