Is there something similar to ec2metadata
in Azure virtual machines?
I need to extract data like the the public hostname or the instance id. In Amazon EC2 instances, I can do this:
$ ec2metadata --instance-id
i-3a1dcfa3
$ ec2metadata --public-hostname
ec2-54-91-124-63.compute-1.amazonaws.com
Azure Functions is the primary equivalent of AWS Lambda in providing serverless, on-demand code. AWS Lambda functionality also overlaps with Azure WebJobs, which let you schedule or continuously run background tasks.
Azure supports common Linux distributions including Red Hat, SUSE, Ubuntu, CentOS, Debian, Oracle Linux, and Flatcar Linux. Create your own Linux virtual machines (VMs), deploy and run containers in Kubernetes, or choose from hundreds of pre-configured images and Linux workloads available in Azure Marketplace.
The Azure hypervisor system is based on Windows Hyper-V.
It seems this question was asked a long time ago, so maybe you already found the answer. If not, though, then have you tried Azure Instance Metadata? (https://docs.microsoft.com/en-us/azure/virtual-machines/virtual-machines-instancemetadataservice-overview) You can do an http request like this:
curl -H Metadata:true "http://169.254.169.254/metadata/instance?api-version=2017-04-02"
The response looks like this:
{
"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": "X.X.X.X"
}
],
"subnet": [
{
"address": "10.1.0.0",
"prefix": "24"
}
]
},
"ipv6": {
"ipAddress": []
},
"macAddress": "000D3AF806EC"
}
]
}
}
Hope this helps! :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With