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
I tried to reproduce the same in my environment and got the results like below:
I executed the
az vm image list-skus
command:To create Azure VM with
2022-datacenter-g2
image, I executed the below command and got the same error:To resolve the error, I tried to create the Azure VM with
Win2022AzureEditionCore
image like below:The Azure VM got created successfully with 2022-datacenter-g2 and in West Europe location like below:
I ran into the same issue and found out that specifying the entire pathn works in Powershell like below.
PublisherName:Offer:Skus:Version
Example: