Equivalent to ec2metadata for Azure Virtual Machines

Is there something similar to ec2metadata in Azure virtual machines?

I need to retrieve data such as a public hostname or instance id. On Amazon EC2 instances, I can do this:

 $ ec2metadata --instance-id i-3a1dcfa3 $ ec2metadata --public-hostname ec2-54-91-124-63.compute-1.amazonaws.com 
+5
source share
1 answer

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! :)

0
source

Source: https://habr.com/ru/post/1211256/


All Articles