Hello, actually this is a SKU Basic LB. Hower I have tried to create a new load balancer and everythink works. So this is probably bug of a Azure Portal where I had the original LB created.
Az Powershell add VMs to a backend pool
I have following script that works only if there is only one machine in the foreach loop.
I can see at the backend pool at Azure portal that all machines are in backend pool but lb doesn't accept any connection. If I remove all from the backend pool except one, the lb starts accepting connections.
$loadBalancer = Get-AzLoadBalancer -ResourceGroupName $lbRgName -Name $lbName
$backendPool = Get-AzLoadBalancerBackendAddressPoolConfig -Name $lbBackPoolName -LoadBalancer $loadBalancer
if ($null -eq $backendPool)
{
throw "Backend pool $lbBackPoolName not found for $lbName"
}
$virtualMachines = Get-AzVM -ResourceGroupName $rgName
foreach ($vm in $virtualMachines)
{
$nic = Get-AzNetworkInterface -ResourceGroupName $rgName | Where-Object {$_.Id -eq $vm.NetworkProfile.NetworkInterfaces.Id}
$ipCfg = $nic.IpConfigurations | Where-Object {$_.Primary}
$ipCfg.LoadBalancerBackendAddressPools.Add($backendPool)
Set-AzNetworkInterface -NetworkInterface $nic
}
2 answers
Sort by: Most helpful
-
-
ChaitanyaNaykodi-MSFT 26,966 Reputation points Microsoft Employee
2024-01-13T01:56:58.9966667+00:00 Thank you for getting back and letting us know that the issue was resolved.
Actually, IP based backends can only be used for Standard Load Balancers SKU. This is currently documented here. I think the new load balancer you created will be of Standard SKU.
Hope this helps! Please let me know if you have any additional questions. Thank you!