From 4e7f42b7c11890cfc586f80d5ee8eb41b82895f3 Mon Sep 17 00:00:00 2001 From: ampravinr <40807962+ampravinr@users.noreply.github.com> Date: Wed, 19 Apr 2023 21:06:58 -0700 Subject: [PATCH] Parsing Skip token for next call (#21600) * Parsing Skip token for next call * Change log --- src/Billing/Billing/ChangeLog.md | 1 + .../GetAzureRmConsumptionPriceSheet.cs | 22 +++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/src/Billing/Billing/ChangeLog.md b/src/Billing/Billing/ChangeLog.md index d123ad5b71ff..6808c4b0a4a4 100644 --- a/src/Billing/Billing/ChangeLog.md +++ b/src/Billing/Billing/ChangeLog.md @@ -18,6 +18,7 @@ - Additional information about change #1 --> ## Upcoming Release +* Fixed skip token for Consumption PriceSheet cmdlet ## Version 2.0.1 * Fixed pagination for `Get-AzConsumptionPriceSheet` cmdlet diff --git a/src/Billing/Consumption/Cmdlets/GetAzureRmConsumptionPriceSheet.cs b/src/Billing/Consumption/Cmdlets/GetAzureRmConsumptionPriceSheet.cs index e2bd233b4b17..868ac2910cb7 100644 --- a/src/Billing/Consumption/Cmdlets/GetAzureRmConsumptionPriceSheet.cs +++ b/src/Billing/Consumption/Cmdlets/GetAzureRmConsumptionPriceSheet.cs @@ -68,6 +68,17 @@ public override void ExecuteCmdlet() expand, skipToken, numberToFetch); UpdateResult(result, priceSheet); nextLink = priceSheet?.NextLink; + + if (!string.IsNullOrWhiteSpace(nextLink)) + { + string queryString = new Uri(nextLink).Query; + var queryDictionary = System.Web.HttpUtility.ParseQueryString(queryString); + + if (queryDictionary.AllKeys.Contains("skipToken")) + { + skipToken = queryDictionary["skipToken"]; + } + } } while (!this.Top.HasValue && !string.IsNullOrWhiteSpace(nextLink)); } else @@ -77,6 +88,17 @@ public override void ExecuteCmdlet() priceSheet = ConsumptionManagementClient.PriceSheet.Get(expand, skipToken, numberToFetch); UpdateResult(result, priceSheet); nextLink = priceSheet?.NextLink; + + if (!string.IsNullOrWhiteSpace(nextLink)) + { + string queryString = new Uri(nextLink).Query; + var queryDictionary = System.Web.HttpUtility.ParseQueryString(queryString); + + if (queryDictionary.AllKeys.Contains("skipToken")) + { + skipToken = queryDictionary["skipToken"]; + } + } } while (!this.Top.HasValue && !string.IsNullOrWhiteSpace(nextLink)); } }