Skip to content

Commit

Permalink
Merge pull request #125 from thefrooh/main
Browse files Browse the repository at this point in the history
Fix HttpClient BaseAddress setting
  • Loading branch information
mivano authored Mar 19, 2024
2 parents d2773d6 + 0fac38b commit 526ada7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
9 changes: 6 additions & 3 deletions src/CostApi/AzureCostApiRetriever.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,12 @@ private async Task<HttpResponseMessage> 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,
Expand Down
9 changes: 6 additions & 3 deletions src/CostApi/AzurePriceRetriever.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,13 @@ public AzurePriceRetriever(IHttpClientFactory httpClientFactory)

public async Task<IEnumerable<PriceRecord>> 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<PriceRecord>();
string? url = "https://prices.azure.com/api/retail/prices?api-version=2023-01-01-preview&currencyCode='" + currencyCode + "'";
string? url = "api/retail/prices?api-version=2023-01-01-preview&currencyCode='" + currencyCode + "'";

// Append the filter to the URL if it's provided
if (!string.IsNullOrWhiteSpace(filter))
Expand Down

0 comments on commit 526ada7

Please sign in to comment.