Hi @Givary-MSFT ,
I understand that extracting this information from the portal could be challenging, however we may extract this information from the Json configuration of the Azure load balancer and using Powershell on the JSON output.
- First to load the configuration of the Azure Load balancer go to Loadbalancer on Azure Portal and load the JSON View as shown below
- Once JSON configuration is loaded, save the configuration and assign it to a JSON Variable $jsonConfig.
Below the sample LB configuration
# Sample JSON configuration of the load balancer
This configuration includes:
- Four frontend IP configurations, each with a different public IP address.
- Four backend address pools, each with different VM NICs.
- Four load balancing rules, each associated with a different frontend IP and backend pool.
- A health probe to check the health of the backend instances.
# Sample JSON configuration of the load balancer
$jsonConfig = @'
{
"name": "myLoadBalancer",
"location": "eastus",
"properties": {
"frontendIPConfigurations": [
{
"name": "LoadBalancerFrontEnd1",
"properties": {
"publicIPAddress": {
"id": "/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.Network/publicIPAddresses/{public-ip1-name}"
}
}
},
{
"name": "LoadBalancerFrontEnd2",
"properties": {
"publicIPAddress": {
"id": "/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.Network/publicIPAddresses/{public-ip2-name}"
}
}
},
{
"name": "LoadBalancerFrontEnd3",
"properties": {
"publicIPAddress": {
"id": "/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.Network/publicIPAddresses/{public-ip3-name}"
}
}
},
{
"name": "LoadBalancerFrontEnd4",
"properties": {
"publicIPAddress": {
"id": "/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.Network/publicIPAddresses/{public-ip4-name}"
}
}
}
],
"backendAddressPools": [
{
"name": "myBackendPool1",
"properties": {
"backendIPConfigurations": [
{
"id": "/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.Network/networkInterfaces/{nic1-name}/ipConfigurations/ipconfig1"
},
{
"id": "/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.Network/networkInterfaces/{nic2-name}/ipConfigurations/ipconfig1"
}
]
}
},
{
"name": "myBackendPool2",
"properties": {
"backendIPConfigurations": [
{
"id": "/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.Network/networkInterfaces/{nic3-name}/ipConfigurations/ipconfig1"
},
{
"id": "/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.Network/networkInterfaces/{nic4-name}/ipConfigurations/ipconfig1"
}
]
}
},
{
"name": "myBackendPool3",
"properties": {
"backendIPConfigurations": [
{
"id": "/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.Network/networkInterfaces/{nic5-name}/ipConfigurations/ipconfig1"
},
{
"id": "/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.Network/networkInterfaces/{nic6-name}/ipConfigurations/ipconfig1"
}
]
}
},
{
"name": "myBackendPool4",
"properties": {
"backendIPConfigurations": [
{
"id": "/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.Network/networkInterfaces/{nic7-name}/ipConfigurations/ipconfig1"
},
{
"id": "/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.Network/networkInterfaces/{nic8-name}/ipConfigurations/ipconfig1"
}
]
}
}
],
"loadBalancingRules": [
{
"name": "rule1",
"properties": {
"frontendIPConfiguration": {
"id": "/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.Network/loadBalancers/myLoadBalancer/frontendIPConfigurations/LoadBalancerFrontEnd1"
},
"backendAddressPool": {
"id": "/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.Network/loadBalancers/myLoadBalancer/backendAddressPools/myBackendPool1"
},
"protocol": "Tcp",
"frontendPort": 80,
"backendPort": 80,
"enableFloatingIP": false,
"idleTimeoutInMinutes": 4,
"loadDistribution": "Default",
"probe": {
"id": "/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.Network/loadBalancers/myLoadBalancer/probes/probe1"
}
}
},
{
"name": "rule2",
"properties": {
"frontendIPConfiguration": {
"id": "/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.Network/loadBalancers/myLoadBalancer/frontendIPConfigurations/LoadBalancerFrontEnd2"
},
"backendAddressPool": {
"id": "/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.Network/loadBalancers/myLoadBalancer/backendAddressPools/myBackendPool2"
},
"protocol": "Tcp",
"frontendPort": 443,
"backendPort": 443,
"enableFloatingIP": false,
"idleTimeoutInMinutes": 4,
"loadDistribution": "Default",
"probe": {
"id": "/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.Network/loadBalancers/myLoadBalancer/probes/probe2"
}
}
},
{
"name": "rule3",
"properties": {
"frontendIPConfiguration": {
"id": "/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.Network/loadBalancers/myLoadBalancer/frontendIPConfigurations/LoadBalancerFrontEnd3"
},
"backendAddressPool": {
"id": "/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.Network/loadBalancers/myLoadBalancer/backendAddressPools/myBackendPool3"
},
"protocol": "Tcp",
"frontendPort": 8080,
"backendPort": 8080,
"enableFloatingIP": false,
"idleTimeoutInMinutes": 4,
"loadDistribution": "Default",
"probe": {
"id": "/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.Network/loadBalancers/myLoadBalancer/probes/probe3"
}
}
},
{
"name": "rule4",
"properties": {
"frontendIPConfiguration": {
"id": "/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.Network/loadBalancers/myLoadBalancer/frontendIPConfigurations/LoadBalancerFrontEnd4"
},
"backendAddressPool": {
"id": "/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.Network/loadBalancers/myLoadBalancer/backendAddressPools/myBackendPool4"
},
"protocol": "Tcp",
"frontendPort": 8443,
"backendPort": 8443,
"enableFloatingIP": false,
"idleTimeoutInMinutes": 4,
"loadDistribution": "Default",
"probe": {
"id": "/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.Network/loadBalancers/myLoadBalancer/probes/probe4"
}
}
}
],
"probes": [
{
"name": "probe1",
"properties": {
"protocol": "Http",
"port": 80,
"requestPath": "/healthcheck1",
"intervalInSeconds": 5,
"numberOfProbes": 2
}
},
{
"name": "probe2",
"properties": {
"protocol": "Http",
"port": 443,
"requestPath": "/healthcheck2",
"intervalInSeconds": 5,
"numberOfProbes": 2
}
},
{
"name": "probe3",
"properties": {
"protocol": "Http",
"port": 8080,
"requestPath": "/healthcheck3",
"intervalInSeconds": 5,
"numberOfProbes": 2
}
},
{
"name": "probe4",
"properties": {
"protocol": "Http",
"port": 8443,
"requestPath": "/healthcheck4",
"intervalInSeconds": 5,
"numberOfProbes": 2
}
}
]
}
}
'@
- Open PowerShell in your machine and run below command
# Convert JSON string to PowerShell object
$config = $jsonConfig | ConvertFrom-Json
# Create a map of frontend public IP to backend pool
$ipToBackendPool = @{}
# Extract frontend IP configurations
$frontendIPs = @{}
foreach ($item in $config.properties.frontendIPConfigurations) {
Write-Output "Processing frontend IP configuration: $($item.name)"
$frontendIPs[$item.name] = $item.properties.publicIPAddress.id
}
# Debugging output for frontend IPs
Write-Output "Frontend IPs:"
$frontendIPs
# Extract backend pools
$backendPools = @{}
foreach ($item in $config.properties.backendAddressPools) {
$backendPools[$item.name] = $item.properties.backendIPConfigurations
}
# Debugging output for backend pools
Write-Output "Backend Pools:"
$backendPools
# Map frontend IP to backend pool using load balancing rules
foreach ($rule in $config.properties.loadBalancingRules) {
$frontendIPName = $rule.properties.frontendIPConfiguration.id.Split('/')[-1]
$backendPoolName = $rule.properties.backendAddressPool.id.Split('/')[-1]
$frontendIP = $frontendIPs[$frontendIPName]
$backendPool = $backendPools[$backendPoolName]
if ($frontendIP -and $backendPool) {
if (-not $ipToBackendPool.ContainsKey($frontendIP)) {
$ipToBackendPool[$frontendIP] = @()
}
$ipToBackendPool[$frontendIP] += $backendPool
}
}
# Debugging output for IP to Backend Pool map
Write-Output "IP to Backend Pool Map:"
$ipToBackendPool
# Convert the map to JSON and print it
$ipToBackendPoolJson = $ipToBackendPool | ConvertTo-Json -Depth 4
Write-Output "IP to Backend Pool JSON:"
Write-Output $ipToBackendPoolJson
- Sample Output
{
"/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.Network/publicIPAddresses/{public-ip2-name}": [
{
"id": "/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.Network/networkInterfaces/{nic3-name}/ipConfigurations/ipconfig1"
},
{
"id": "/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.Network/networkInterfaces/{nic4-name}/ipConfigurations/ipconfig1"
}
],
"/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.Network/publicIPAddresses/{public-ip3-name}": [
{
"id": "/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.Network/networkInterfaces/{nic5-name}/ipConfigurations/ipconfig1"
},
{
"id": "/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.Network/networkInterfaces/{nic6-name}/ipConfigurations/ipconfig1"
}
],
"/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.Network/publicIPAddresses/{public-ip4-name}": [
{
"id": "/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.Network/networkInterfaces/{nic7-name}/ipConfigurations/ipconfig1"
},
{
"id": "/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.Network/networkInterfaces/{nic8-name}/ipConfigurations/ipconfig1"
}
],
"/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.Network/publicIPAddresses/{public-ip1-name}": [
{
"id": "/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.Network/networkInterfaces/{nic1-name}/ipConfigurations/ipconfig1"
},
{
"id": "/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/Microsoft.Network/networkInterfaces/{nic2-name}/ipConfigurations/ipconfig1"
}
]
}
If the below answer addressed your query, please don’t forget to click "Accept the answer" and Up-Vote for the same, which might be beneficial to other community members reading this thread. And, if you have any further query do let us know.
Thanks,
Ujjawal Tyagi