List the IP Address of Azure Load Balancers

Today I was tasked with inventorying assets and defining if they were involved with handling ePHI (electronic Personal Health Information). The challenge I was present was being given only the IP Address of the Load Balancer and the default name created by Azure - "kubernetes". Anyone working with large scale infrastructure and deployments can quickly realize looking at a list of 100 IP addresses quickly becomes a monotonous task to identify each one individually, especially in Azure.

After painfully going through the first Load Balancer I found it necessary to convert the steps below into a one liner.

List all Load Balancers in the Subscription
$ az network lb list

List all frontend IP Objects in the Load Balancer
$ az network lb frontend-ip list --lb-name kubernetes --resource-group <your resource group>

Show the AzureRM Resource ID for the IP object.
$ az network lb frontend-ip show --name <object name> --lb-name kubernetes --resource-group <resource group name> --output json --query

Show the actual IP Address
$ az network public-ip show --id <azurerm resource id> --query ipAddress

So you can see in the list above it takes 4 separate commands to get to the IP Address. You can shortcut that list if you know the specific objects in the detailed output. So now below you will see a shorter version of the 4 steps above. The output of the command below will be the Azure Resource ID and the IP Address. I find the Resource ID plentiful for the environments I maintain as the Resource Group name tells me Region, Product and Environment each resource lives in.1 (Example ue-xyz-dev-<extra details>. Where "xyz" is the product abbreviation). You may need to alter this to be more detailed for your needs.

$ for id in $(az network lb list --output json|jq -r '.[].frontendIpConfigurations[]');do print "\n${id}"; az network public-ip show --output tsv --id ${id} --query 'ipAddress'; done

Hopefully this will save you some time looking up resources in your Azure environment(s).