new version

FAQ: Find Latest Version of Image in Azure

Q: How can I easily find the latest version of an image in Azure?

A: Microsoft provides multiple versions of many images based on patch levels. Often you just want to use the latest version of an image. I created a PowerShell script that fetches all the versions for a specific operating system (which you can change) and then orders the versions so the newest version is the first element:

$images = Get-AzureVMImage
$2012R2imgs = @() #Create array of objects
foreach ($image in $images)
   if ($image.Label.Contains("Windows Server 2012 R2 Datacenter"))
      $2012R2imgs += $image

$2012R2imgs = $2012R2imgs | Sort-Object PublishedDate -Descending #put the newest first which is the highest patched version

$2012R2imgs | ft Label,ImageName,LogicalSizeInGB -AutoSize

To use the latest version, just access the element $2012R2imgs[0] (for example, as part of provisioning I would use -ImageName $2012R2imgs[0].ImageName). The following code snippet shows this in practice:

$NewVM = New-AzureVMConfig -Name $VMName -InstanceSize 'Basic_A2' -ImageName $2012R2imgs[0].ImageName |
    Add-AzureProvisioningConfig -Windows -AdminUsername $admin -Password $myPwd -NoRDPEndpoint -NoWinRMEndpoint|
    Set-AzureSubnet 'App-Net'
Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.