Getting Azure VM Instance ID from within a VM and linking it with imported Azure VM instances

Tyler Durden picture Tyler Durden · Jan 18, 2016 · Viewed 7.7k times · Source

I am developing a client-server application where I want the client (Azure VM) to send its instance ID to the server. The server will use this instance ID to link it with the corresponding VM from the list of imported Azure instances (using Azure cloud credentials).

I am facing some problems:

I didn't have this problem for AWS as I clearly get instance ID on both sides.

Answer

Iurii Vasylenko picture Iurii Vasylenko · Jul 29, 2019

Maybe you could use something like:

curl -H Metadata:true "http://169.254.169.254/metadata/instance/compute/vmId?api-version=2017-08-01&format=text"

As described here: https://docs.microsoft.com/en-us/azure/virtual-machines/windows/instance-metadata-service