Aracılığıyla paylaş


CosmosClientBuilder.WithHttpClientFactory(Func<HttpClient>) Method

Definition

Sets a delegate to use to obtain an HttpClient instance to be used for HTTPS communication.

public Microsoft.Azure.Cosmos.Fluent.CosmosClientBuilder WithHttpClientFactory (Func<System.Net.Http.HttpClient> httpClientFactory);
member this.WithHttpClientFactory : Func<System.Net.Http.HttpClient> -> Microsoft.Azure.Cosmos.Fluent.CosmosClientBuilder
Public Function WithHttpClientFactory (httpClientFactory As Func(Of HttpClient)) As CosmosClientBuilder

Parameters

httpClientFactory
Func<HttpClient>

A delegate function to generate instances of HttpClient.

Returns

The CosmosClientBuilder object

Remarks

HTTPS communication is used when ConnectionMode is set to Gateway for all operations and when ConnectionMode is Direct (default) for metadata operations.

Useful in scenarios where the application is using a pool of HttpClient instances to be shared, like ASP.NET Core applications with IHttpClientFactory or Blazor WebAssembly applications.

Applies to

See also