Search This Blog

Tuesday, April 30, 2019

Get Public IP address of Azure VM from shell on VM

Sometimes you need to get an IP address of the VM from inside of it. You can do this relatively simple from Azure VM with curl and jq thanks to Metadata endpoint as described in this document

And if you need the public IP address of interface eth0 this is the command:

curl -H Metadata:true| jq '.network.interface[0].ipv4.ipAddress[0].publicIpAddress'