Fix HttpClient BaseAddress setting #125
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When executing
azure-cost
with default commandaccumulatedCost
, I encountered the following error message: "This instance has already started one or more requests. Properties can only be modified before sending the first request."The PR #122 added the ability to select CostApi and PriceApi base URL which seems to broke at least
accumulatedCost
command. This is caused by setting the BaseAddress property of a HttpClient that has already made a request before. TheaccumulatedCost
command uses the same instance ofICostRetriever
to make multiple HTTP requests, and when making the second call, the error above occurs.To overcome this issue, the BaseAddress should be set for the HttpClient only if it differs from the default value, which will ideally not change throughout its lifecycle.
I also removed the hardcoded PriceApi address that is probably a leftover, and use the default or the one set through CLI args.