Why I'm getting currently a Bad request with a New-AzGalleryImageVersion but same command was working last month?

Ana Cortazar 41 Reputation points

The sourceImageId is in a different subscription of the Gallery where the Image version must to be created.

Command -->

New-AzGalleryImageVersion -ResourceGroupName resourceGroupGalleryWhereImageVersionWillbeCreated `

                                   -GalleryName `GalleryName`  `

                                   -GalleryImageDefinitionName  `ImgDefName`  `

                                   -Name `0.0.1`  `

                                   -Location `locationXYZ`  `

                                   -StorageAccountType `storageAccountTypeName`  `

                                   -sourceImageId '/subscriptions/*`subscriptionVmSource`*/resourceGroups/`resourceGroupVmsource`/providers/Microsoft.Compute/virtualMachines/`VmSourceID`'

New-AzGalleryImageVersion: The gallery image version source id: '/subscriptions/3e72c452-a40b-4e4a-8d2a-ce54e2258366/resourceGroups/VMBaseLab-WS22-1155-DD-019384/providers/Microsoft.Compute/virtualMachines/WS22-1155-DD' must be specified in 'galleryImageVersion.properties.storageProfile.source.virtualMachineId'.

ErrorCode: InvalidParameter

ErrorMessage: The gallery image version source id: '/subscriptions/3e72c452-a40b-4e4a-8d2a-ce54e2258366/resourceGroups/VMBaseLab-WS22-1155-DD-019384/providers/Microsoft.Compute/virtualMachines/WS22-1155-DD' must be specified in 'galleryImageVersion.properties.storageProfile.source.virtualMachineId'.

ErrorTarget: galleryImageVersion.properties.storageProfile.source

StatusCode: 400

ReasonPhrase: Bad Request

OperationID : 008431ad-c43c-45a1-9e66-15eb41ee9a8b

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
7,395 questions
{count} votes

Accepted answer
  1. deherman-MSFT 34,686 Reputation points Microsoft Employee

    @Ana Cortazar

    I'm glad that you were able to resolve your issue and thank you for posting your solution so that others experiencing the same thing can easily reference this! Since the Microsoft Q&A community has a policy that "The question author cannot accept their own answer. They can only accept answers by others ", I'll repost your solution in case you'd like to "Accept " the answer.

    Issue: Unable to run New-AzGalleryImageVersion

    Solution: You were utilizing

    The ID of the source image from which the Image Version is going to be created.

    You changed to

    The resource Id of the source virtual machine. Only required when capturing a virtual machine to source this Gallery Image Version.

    This appears to be related to this same GitHub issue. This has been reported to our service team.

    If you have any other questions or are still running into more issues, please let me know. Thank you again for your time and patience throughout this issue.

    Please remember to "Accept Answer" if any answer/reply helped, so that others in the community facing similar issues can easily find the solution.

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Ana Cortazar 41 Reputation points

    Here is the Terraform version for same issue, if maybe it ca be useful to reply the problem:

    resource "azurerm_image" "source_image" {  
      provider            = azurerm.source
      name                = var.virtual_machine_source_name  
      resource_group_name = var.virtual_machine_source_resource_group  
      location            = var.virtual_machine_source_location
      source_virtual_machine_id = "/subscriptions/${var.virtual_machine_source_subscription}/resourceGroups/${var.virtual_machine_source_resource_group}/providers/Microsoft.Compute/virtualMachines/${var.virtual_machine_source_name}" 
     resource "azurerm_shared_image_gallery" "example" {  
      provider            = azurerm.target 
      name                = var.gallery_name
      resource_group_name = var.gallery_resource_group
      location            = var.gallery_location
    resource "azurerm_shared_image" "example" {
      provider            = azurerm.target
      name                = var.image_definition_name
      gallery_name        = azurerm_shared_image_gallery.example.name                   
      resource_group_name = azurerm_shared_image_gallery.example.resource_group_name    
      location            = azurerm_shared_image_gallery.example.location               
      os_type             = var.virtual_machine_source_os
      identifier {
        publisher = var.image_definition_publisher 
        offer     = var.image_definition_offer
        sku       = var.image_definition_sku
    resource "azurerm_shared_image_version" "example" {
      provider                 = azurerm.target
      name                     = var.image_definition_version  
      gallery_name             = azurerm_shared_image_gallery.example.name              
      image_name               = azurerm_shared_image.example.name  
      resource_group_name      = azurerm_shared_image.example.resource_group_name  
      location                 = azurerm_shared_image.example.location  
      managed_image_id         = azurerm_image.source_image.source_virtual_machine_id
      target_region {  
        name                   = azurerm_shared_image_gallery.example.location          
        regional_replica_count = 1  
        storage_account_type   = "Standard_LRS"  

    And Here is the Error got -->

    Error: creating Shared Image Version: (Version Name "0.0.4" / Image Name "ImgW10-1155" / Gallery Name "Gallery1155" / Resource Group "rg-cgsaz-images-galleries-001"): compute.GalleryImageVersionsClient#CreateOrUpdate: Failure sending request: StatusCode=400 -- Original Error: Code="InvalidParameter" Message="The source VM '/subscriptions/3e72c452-a40b-4e4a-8d2a-123/resourceGroups/VMBASELAB-WS22-1155-DD-019384/providers/Microsoft.Compute/virtualMachines/WS22-1155-DD' is a cross subscription source for the galleryImageVersion created in subscription '01fe287e-c0d1-4eff-a5ef-1703123'. Please retry the call by specifying the VM id in 'galleryImageVersion.properties.storageProfile.source.virtualMachineId' instead. See https://aka.ms/acgsecurityupdates for more details." Target="galleryImageVersion.properties.storageProfile.source.id"

    0 comments No comments