Azure CosmosDB libraries for .NET


Azure CosmosDB is a distributed and scalable data store, supporting multiple different types of databases.

Client library

Use the CosmosDB .NET client library to access and store data in a CosmosDB data store.

Install the NuGet package directly from the Visual Studio Package Manager console or with the .NET Core CLI.

Visual Studio Package Manager

Install-Package Microsoft.Azure.DocumentDB.Core


dotnet add package Microsoft.Azure.DocumentDB.Core

Code Example

This example connects to an existing CosmosDB DocumentDB API database, reads a document from a collection, and deserializes it as an Item object.

/* Include this "using" directive...
using Microsoft.Azure.Documents.Client;

DocumentClient client = new DocumentClient(endpointUri, authKeyString);
Uri documentUri = UriFactory.CreateDocumentUri("MyDatabaseName", "MyCollectionName", "DocumentId");
// "Item" is a class defined elsewhere...
Item item = client.ReadDocumentAsync<Item>(documentUri).ToString()).Result;


View the complete list of Azure Cosmos DB samples.