Skip to content

Instantly share code, notes, and snippets.

@ealsur
Created August 14, 2020 23:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ealsur/491bbbe78e5349d6f0ff3bb3fd051515 to your computer and use it in GitHub Desktop.
Save ealsur/491bbbe78e5349d6f0ff3bb3fd051515 to your computer and use it in GitHub Desktop.
public void ConfigureServices(IServiceCollection services)
{
services.AddHttpClient();
services.AddSingleton<CosmosClient>(serviceProvider =>
{
IHttpClientFactory httpClientFactory = serviceProvider.GetRequiredService<IHttpClientFactory>();
CosmosClientOptions cosmosClientOptions = new CosmosClientOptions()
{
HttpClientFactory = httpClientFactory.CreateClient
};
return new CosmosClient("<connection-string>", cosmosClientOptions);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment