Why do some CosmosDB/C# examples use HttpClient in "OnConfiguring"?

Siegfried Heintze 1,861 Reputation points
2021-12-06T22:34:07.697+00:00

Why does CosmosPrimitiveTypesSample.cs incorporate a httpClient? What is this used for?

Azure Cosmos DB
Azure Cosmos DB
An Azure NoSQL database service for app development.
1,543 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Anurag Sharma 17,591 Reputation points
    2021-12-07T04:17:06.93+00:00

    Hi @Siegfried Heintze , welcome to Microsoft Q&A forum.

    Use of HttpClient in OnConfiguring method is for managing multiple connections and to optimize using them. I would request you to once go through the below article which talks about the same in details:

    HttpClientFactory in the Azure Cosmos DB .NET SDK

    We can always choose to write the code our way, this is just a way to handle lot of connections. Please let us know if you need more details.

    0 comments No comments