Skip to content

Latest commit

 

History

History
18 lines (11 loc) · 1.48 KB

File metadata and controls

18 lines (11 loc) · 1.48 KB

Serverless recipes with a Cosmos DB custom client

<- Back to the root

The following project contains a sample on maintaining and reusing a Azure Cosmos DB V3 client. The concept is valid for any HTTP-based client library/SDK.

It contains a single sample:

  1. Startup: Create and maintain a custom CosmosClient instance to be reused in all the Function's executions through ASP.NET Core Dependency Injection.
  2. HttpTriggerToStaticClient: Pulls in the singleton CosmosClient and when the Function receives a POST with a particular payload, it uses it to store it as a new document.

How to run this sample

You can use Visual Studio Code, Visual Studio or even the Azure Functions' CLI. You only need to customize the local.settings.json file to match the Cosmos DB Connection String, Preferred Region, Database name, and Container name on which you want the client to be created and documents to be saved.

Useful links