Azure Public facing Loadbalancers

57 views Asked by At

I want to list all loadbalancers in Azure which have public IP address but I get only a subset and not the entire result.

 var credentials = SdkContext.AzureCredentialsFactory
                                          .FromServicePrincipal(clientId, secret,
                                           tenantId, AzureEnvironment.AzureGlobalCloud);

var azure = Microsoft.Azure.Management.Fluent.Azure
                                .Configure()
                               .Authenticate(credentials).WithDefaultSubscription();

foreach (var subscription in azure.Subscriptions.List())
{
      var loadbalancers = azure.LoadBalancers;

      foreach (var loadbalancer in loadbalancers.List())
      {
        if (loadbalancer.PublicFrontends.Count >= 1)
        {
          writelog("load balancer:" + loadbalancer.Name);
        }
      }
}
1

There are 1 answers

0
Arindam On BEST ANSWER

You need to authenticate to each subscription and then get the list of load balancer.