Azure Cosmos DB libraries for .NET


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

Get started with Cosmos DB.

Client library

Use the Azure Cosmos DB .NET client library to access and store data in an existing Azure Cosmos DB data store. To automate creation of a new Azure Cosmos DB account, use the Azure portal, CLI, or PowerShell.

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 Azure Cosmos DB SQL 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");
SomeClass myObject = client.ReadDocumentAsync<SomeClass>(documentUri).ToString().Result;


View the complete list of Azure Cosmos DB samples.