Skip to content

Commit

Permalink
Mitigated Azure REST API issue (#258)
Browse files Browse the repository at this point in the history
  • Loading branch information
shibayan authored Dec 8, 2020
1 parent 544889b commit cbc78f1
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions AppService.Acmebot/Internal/AzureSdkExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;

Expand Down Expand Up @@ -91,6 +92,7 @@ public static async Task<IReadOnlyList<ResourceGroup>> ListAllAsync(this IResour
return resourceGroups;
}

#if false
public static async Task<IReadOnlyList<Site>> ListByResourceGroupAllAsync(this IWebAppsOperations operations, string resourceGroupName)
{
var sites = new List<Site>();
Expand All @@ -108,6 +110,41 @@ public static async Task<IReadOnlyList<Site>> ListByResourceGroupAllAsync(this I

return sites;
}
#else
public static async Task<IReadOnlyList<Site>> ListByResourceGroupAllAsync(this IWebAppsOperations operations, string resourceGroupName)
{
var sites = new List<Site>();

var list = await operations.ListByResourceGroupAsync(resourceGroupName);

sites.AddRange(list);

while (list.NextPageLink != null)
{
list = await operations.ListByResourceGroupNextAsync(list.NextPageLink);

sites.AddRange(list);
}

var slots = new List<Site>();

foreach (var site in sites)
{
var listSlots = await operations.ListSlotsAsync(resourceGroupName, site.Name);

slots.AddRange(listSlots);

while (listSlots.NextPageLink != null)
{
listSlots = await operations.ListSlotsNextAsync(listSlots.NextPageLink);

slots.AddRange(listSlots);
}
}

return sites.Concat(slots).OrderBy(x => x.Name).ToArray();
}
#endif

public static async Task<IReadOnlyList<Certificate>> ListAllAsync(this ICertificatesOperations operations)
{
Expand Down

0 comments on commit cbc78f1

Please sign in to comment.