Skip to content

Files

Latest commit

 

History

History
95 lines (79 loc) · 3.46 KB

howto-load-balancer-imds.md

File metadata and controls

95 lines (79 loc) · 3.46 KB
title titleSuffix description services author ms.service ms.topic ms.date ms.author
Retrieve load balancer metadata using Azure Instance Metadata Service (IMDS)
Azure Load Balancer
Get started learning how to retrieve load balancer metadata using Azure Instance Metadata Service.
load-balancer
greg-lindsay
load-balancer
how-to
02/12/2021
greglin

Retrieve load balancer metadata using Azure Instance Metadata Service (IMDS)

Prerequisites

Sample request and response

Important

This example bypasses proxies. You must bypass proxies when querying IMDS. For more information, see Proxies.

Schema breakdown

Data Description Version introduced
publicIpAddresses The instance level Public or Private IP of the specific Virtual Machine instance 2020-10-01
inboundRules List of load balancing rules or inbound NAT rules using which the Load Balancer directs traffic to the specific Virtual Machine instance. Frontend IP addresses and the Private IP addresses listed here belong to the Load Balancer. 2020-10-01
outboundRules List of outbound rules by which the Virtual Machine behind Load Balancer sends outbound traffic. Frontend IP addresses and the Private IP addresses listed here belong to the Load Balancer. 2020-10-01
Invoke-RestMethod -Headers @{"Metadata"="true"} -Method GET -NoProxy -Uri "http://169.254.169.254:80/metadata/loadbalancer?api-version=2020-10-01" | ConvertTo-Json

Note

The -NoProxy parameter was introduced in PowerShell 6.0. If you are using an older version of PowerShell, remove -NoProxy in the request body and make sure you are not using a proxy while retrieving IMDS info. Learn more here.

curl -H "Metadata:true" --noproxy "*" "http://169.254.169.254:80/metadata/loadbalancer?api-version=2020-10-01"

Sample response

{
   "loadbalancer": {
    "publicIpAddresses":[
      {
         "frontendIpAddress":"51.0.0.1",
         "privateIpAddress":"10.1.0.4"
      }
   ],
   "inboundRules":[
      {
         "frontendIpAddress":"50.0.0.1",
         "protocol":"tcp",
         "frontendPort":80,
         "backendPort":443,
         "privateIpAddress":"10.1.0.4"
      },
      {
         "frontendIpAddress":"2603:10e1:100:2::1:1",
         "protocol":"tcp",
         "frontendPort":80,
         "backendPort":443,
         "privateIpAddress":"ace:cab:deca:deed::1"
      }
   ],
   "outboundRules":[
      {
         "frontendIpAddress":"50.0.0.1",
         "privateIpAddress":"10.1.0.4"
      },
      {
         "frotendIpAddress":"2603:10e1:100:2::1:1",
         "privateIpAddress":"ace:cab:deca:deed::1"
      }
    ]
   }
}

Next steps

Common error codes and troubleshooting steps

Learn more about Azure Instance Metadata Service

Retrieve all metadata for an instance

Deploy a standard load balancer