0

I need to create a Windows 10 VM in Azure through a script that can be called in a CI pipeline in order to create a nested android emulator for automated UI testing. The script creates the VM using the new Azure powershell modules (in this case Az.Compute), but it seems that the cmdlet New-AzVm only accepts a limited list of image names in its -ImageName parameter. Is there a way to specify to this cmdlet that I want to create a Windows 10 VM?

I have tried using the format Publisher:Offer:Sku:Version for a Windows 10 Pro image, but it was unable to recognize this format.

$ImageName = "MicrosoftWindowsDesktop:Windows10:rs5-pro:latest"

# Create the VM
New-AzVM `
  -ResourceGroupName $ResourceGroup `
  -Name $VmName `
  -Location $Location `
  -ImageName $ImageName `
  -Size $VmSize `
  -VirtualNetworkName $VnetName `
  -SubnetName $SubnetName `
  -SecurityGroupName $NsgName `
  -PublicIpAddressName $PipName `
  -Credential $Cred `
  -OpenPorts 3389 `
  -Verbose

I expected to have a windows 10 vm created in my azure resource group, but instead received the following error:

New-AzVM : Artifact: VMImage was not found. At line:1 char:1 + New-AzVM -ResourceGroup androidexample -Location eastus -ImageName "M ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : CloseError: (:) [New-AzVM], CloudException + FullyQualifiedErrorId : Microsoft.Azure.Commands.Compute.NewAzureVMCommand

1 Answer 1

1

I think it should be "windows-10" instead of windows10. Moreover, use "rs5-pron" or "rs4-pro" instead of "rs5-pro". Also use specific versions like :

"17763.678.1908092216" "17763.737.1909062324"

You can list the offers for example, for west Europe using:

$locName="westeurope"
$pubName="MicrosoftWindowsDesktop"
Get-AzVMImageOffer -Location $locName -PublisherName $pubName | Select Offer

Also for listing SKUs you can use

Get-AzVMImageSku -Location $locName -PublisherName $pubName -Offer $offerName | Select Skus

Also for listing image versions you can use (for example, here for rs5-pron):

$skuName="rs5-pron"
Get-AzVMImage -Location $locName -PublisherName $pubName -Offer $offerName -Sku $skuName | Select Version 

Hope this helps :).

Sign up to request clarification or add additional context in comments.

1 Comment

is there a way to list all the image names to quickly create a VM, say New-AzVm -ResourceGroupName test-grp -Name demovm3 -Location CentralUS -Image win2019datacenter. Now win2019datacenter works just fine, I'd like to know how to list values for Windows 7 and basically every other OS out there easily. I know MS lists some values but I can't figure out what Microsoft means by friendly image names, Please help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.