This question seems to have been asked a long time, so maybe you have already found the answer. If not, have you tried the Azure Instance metadata? ( https://docs.microsoft.com/en-us/azure/virtual-machines/virtual-machines-instancemetadataservice-overview ) You can execute an HTTP request, for example:
curl -H Metadata:true "http://169.254.169.254/metadata/instance?api-version=2017-04-02"
The answer is as follows:
{ "compute": { "location": "westcentralus", "name": "IMDSSample", "offer": "UbuntuServer", "osType": "Linux", "platformFaultDomain": "0", "platformUpdateDomain": "0", "publisher": "Canonical", "sku": "16.04.0-LTS", "version": "16.04.201610200", "vmId": "5d33a910-a7a0-4443-9f01-6a807801b29b", "vmSize": "Standard_A1" }, "network": { "interface": [ { "ipv4": { "ipAddress": [ { "privateIpAddress": "10.1.0.4", "publicIpAddress": "XXXX" } ], "subnet": [ { "address": "10.1.0.0", "prefix": "24" } ] }, "ipv6": { "ipAddress": [] }, "macAddress": "000D3AF806EC" } ] } }
Hope this helps! :)
source share