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