This repo contains samples in various languages to call into Azure Instance Metadata Service from within the VM in Azure. Please refer to LICENSE terms for use.
More details on Azure Instance Metadata service can be found here https://docs.microsoft.com/en-us/azure/virtual-machines/virtual-machines-instancemetadataservice-overview