Uniquely Identify an Azure VM Even after Deprovisioning

Uniquely Identify an Azure VM Even after Deprovisioning

If a VM is deprovisioned in Azure, when it is reprovisioned it will get a new GUID, making it hard to track VMs through management applications.

Q. How can I uniquely identify an Azure VM, even if it's deprovisioned then reprovisioned?

A. If a VM is deprovisioned in Azure, when it is reprovisioned it will get a new GUID, making it hard to track VMs through management applications. To help solve this, Azure gives each VM a unique ID that can be queried from inside the VM using the code below:

$computerSystemProduct = Get-WmiObject -class Win32_ComputerSystemProduct -namespace root\CIMV2
'VM UUID is "{0}"' -f $computerSystemProduct.UUID

This value is stored in the Azure VMs SMBIOS and is durable even if the VM is deallocated then reallocated to the Azure fabric. Note that if you delete the VM then create a new VM using the existing VHDs, then the VM UUID will be reset to a new value.

Hide comments

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.
Publish