diff --git a/src/CostApi/AzureCostApiRetriever.cs b/src/CostApi/AzureCostApiRetriever.cs index f161c00..f889577 100644 --- a/src/CostApi/AzureCostApiRetriever.cs +++ b/src/CostApi/AzureCostApiRetriever.cs @@ -126,9 +126,12 @@ private async Task ExecuteCallToCostApi(bool includeDebugOu AnsiConsole.Write(new JsonText(JsonSerializer.Serialize(payload))); AnsiConsole.WriteLine(); } - - _client.BaseAddress = new Uri(CostApiAddress); - + + if (!string.Equals(_client.BaseAddress?.ToString(), CostApiAddress)) + { + _client.BaseAddress = new Uri(CostApiAddress); + } + var options = new JsonSerializerOptions { DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull, diff --git a/src/CostApi/AzurePriceRetriever.cs b/src/CostApi/AzurePriceRetriever.cs index b8f5858..82223dd 100644 --- a/src/CostApi/AzurePriceRetriever.cs +++ b/src/CostApi/AzurePriceRetriever.cs @@ -15,10 +15,13 @@ public AzurePriceRetriever(IHttpClientFactory httpClientFactory) public async Task> GetAzurePricesAsync(string currencyCode = "USD", string? filter = null) { - _client.BaseAddress = new Uri(PriceApiAddress); - + if (!string.Equals(_client.BaseAddress?.ToString(), PriceApiAddress)) + { + _client.BaseAddress = new Uri(PriceApiAddress); + } + var prices = new List(); - string? url = "https://prices.azure.com/api/retail/prices?api-version=2023-01-01-preview¤cyCode='" + currencyCode + "'"; + string? url = "api/retail/prices?api-version=2023-01-01-preview¤cyCode='" + currencyCode + "'"; // Append the filter to the URL if it's provided if (!string.IsNullOrWhiteSpace(filter))