skip to Main Content

I dont know why I keep getting the error "Invalid image "2022-datacenter-g2". Use a valid image URN, custom image name, custom image id, VHD blob URI, or pick an image from…"

I listed the images using the cli command below :

az vm image list-skus -l westeurope -f WindowsServer -p  MicrosoftWindowsServer

I got the image name from the above which was 2022-datacenter-g2, I then used this in my code $(imagename) contains "2022-datacenter-g2" (–image $(imagename) )

az vm create –name $(vmname) –resource-group $vmrsgname –admin-username $(adminusername) –admin-password $(adminpassword) –image $(imagename) –nics $(nicname) –os-disk-name $(osdiskname) –os-disk-size-gb $(osdisksize) –storage-sku $(storagesku) –size $(vmsize) –computer-name $(computername) –license-type Windows_Server

2

Answers


  1. I tried to reproduce the same in my environment and got the results like below:

    I executed the az vm image list-skus command:

    enter image description here

    To create Azure VM with 2022-datacenter-g2 image, I executed the below command and got the same error:

    az vm create --name testvm --resource-group Rukmini --image 2022-datacenter-g2 
    

    enter image description here

    To resolve the error, I tried to create the Azure VM with Win2022AzureEditionCore image like below:

    az vm create --resource-group Rukmini --name testvmruk --image Win2022AzureEditionCore --location westeurope
    

    The Azure VM got created successfully with 2022-datacenter-g2 and in West Europe location like below:

    enter image description here

    Login or Signup to reply.
  2. I ran into the same issue and found out that specifying the entire pathn works in Powershell like below.
    PublisherName:Offer:Skus:Version

    Example:

    $ImageName = 'MicrosoftWindowsServer:WindowsServer:2022-Datacenter-g2:Latest'
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search