3
votes

I tried to create 2 virtual machines with the same parameters but with 2 different ways:

  1. The Powershell cmdlet:

    New-AzVm -ResourceGroupName $rg -Name "Testing1img" -Credential $credential -Image UbuntuLTS
    
  2. Azure CLI from Powershell:

    az vm create `
      --name "Testing2img" `
      --resource-group $rg `
      --admin-username $credential.UserName `
      --admin-password $credential.Password `
      --image "UbuntuLTS"
    

Both create an Ubuntu LTS VM on the same resource group (different name). The problem I have is that they create VMs with slightly different settings.

In the first case it creates:

  • an Ubuntu 16.04 Linux
  • DNS name is being assigned Trial 1

In the second case we have:

  • an Ubuntu 18.04 Linux
  • No Dns name is being configured Trial 2

Why these (even small) differences? Shouldn't they both create the same exact VMs? Someone asking for an UbuntuLTS would expect the latest available image and not 16.04.

2
I run them directly from MS Terminal (Azure Cloud Shell). I think both are at the latest. The pwsh is at 7.0.3 and the cli at 2.13.0.Efthymios Kalyviotis

2 Answers

1
votes

For New-AzVM you can specify the Ubuntu version with... -Image Canonical:UbuntuServer:18.04-LTS:latest

0
votes

My experience shows that functionalities are often delivered in different time frames for individual tools. I often came across commands that used methods other than those recommended in the documentation.

I'm not sure how this looks like for the PowerShell module but the azure CLI code is available on GitHub. So it's possible to verify which endpoints are used and i think the same is possible for debug mode in PowerShell.

https://github.com/Azure/azure-cli/blob/e4a2e19855b2ff0964d084239de9f3f230e67be4/src/azure-cli/azure/cli/command_modules/vm/custom.py#L682