Azure VM can query the Instance Metadata Service located at 169.254.159.254 for data. However this does not work from within a Windows container running on the VM.
How can a Windows container query the Instance Metadata Service that's only accessible from the host VM?
For example when using a Windows container like this: docker run -it --rm mcr.microsoft.com/windows/servercore:ltsc2019
And querying for data like this: Invoke-RestMethod -Headers @{"Metadata"="true"} -Method GET -Uri http://169.254.169.254/metadata/instance?api-version=2019-06-01
Results in this:
At line:1 char:1
+ Invoke-RestMethod -Headers @{"Metadata"="true"} -Method GET -Uri http ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebExc
eption
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

