我想列出Azure中具有公共IP地址的所有负载均衡器,但我只得到一个子集而不是整个结果。
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);
}
}
}
答案 0 :(得分:1)
您需要对每个订阅进行身份验证,然后获取负载均衡器列表。