Soenneker.Cosmos.Database 11.0.2803

Prefix Reserved
dotnet add package Soenneker.Cosmos.Database --version 11.0.2803
                    
NuGet\Install-Package Soenneker.Cosmos.Database -Version 11.0.2803
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Soenneker.Cosmos.Database" Version="11.0.2803" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Soenneker.Cosmos.Database" Version="11.0.2803" />
                    
Directory.Packages.props
<PackageReference Include="Soenneker.Cosmos.Database" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Soenneker.Cosmos.Database --version 11.0.2803
                    
#r "nuget: Soenneker.Cosmos.Database, 11.0.2803"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Soenneker.Cosmos.Database@11.0.2803
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Soenneker.Cosmos.Database&version=11.0.2803
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.Cosmos.Database&version=11.0.2803
                    
Install as a Cake Tool

alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image

Soenneker.Cosmos.Database

Resolves and caches Azure Cosmos DB Database handles, with optional database creation on first use.

Installation

dotnet add package Soenneker.Cosmos.Database

Configuration

{
  "Azure": {
    "Cosmos": {
      "Endpoint": "https://your-account.documents.azure.com:443/",
      "AccountKey": "your-account-key",
      "DatabaseName": "app",
      "EnsureDatabaseOnFirstUse": true
    }
  }
}

Endpoint, AccountKey, and DatabaseName are required when the service is constructed. EnsureDatabaseOnFirstUse defaults to true; set it to false when this process must not create databases.

Registration and use

using Soenneker.Cosmos.Database.Abstract;
using Soenneker.Cosmos.Database.Registrars;

services.AddCosmosDatabaseUtilAsSingleton();

ICosmosDatabaseUtil databases = serviceProvider.GetRequiredService<ICosmosDatabaseUtil>();
Microsoft.Azure.Cosmos.Database database = await databases.Get(cancellationToken);

The registrar also adds the Cosmos database-setup and client dependencies. The utility is intentionally singleton-scoped so database handles can be reused.

To resolve a database other than the configured default:

Microsoft.Azure.Cosmos.Database archive = await databases.Get(
    endpoint,
    accountKey,
    "archive",
    cancellationToken);

Handles are cached by endpoint, account-key identity, and database name. Concurrent requests for the same key share one initialization.

Deleting a database

await databases.Delete(endpoint, accountKey, "temporary", cancellationToken);

Delete() permanently deletes the database in Cosmos DB and removes its cached handle. With EnsureDatabaseOnFirstUse enabled, deleting a database that does not exist may create it immediately before deleting it because deletion first resolves the handle.

Cosmos SDK and setup failures propagate to the caller. Cancellation is honored during initialization and deletion. Disposing the registered service releases its cache; the Cosmos client dependency owns the underlying clients.

Product Compatible and additional computed target framework versions.
.NET net11.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Soenneker.Cosmos.Database:

Package Downloads
Soenneker.Cosmos.Container.Setup

A utility library for Azure Cosmos container setup operations

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
11.0.2803 0 11/15/2026
11.0.2802 50 11/14/2026
11.0.2801 306 11/12/2026
11.0.2800 152 11/11/2026
11.0.2798 161 11/11/2026
11.0.2797 112 11/11/2026
11.0.2796 152 11/11/2026
11.0.2795 214 11/11/2026
11.0.2794 95 11/11/2026
11.0.2792 180 11/11/2026
11.0.2791 698 11/7/2026
11.0.2790 270 11/6/2026
11.0.2789 608 11/3/2026
11.0.2788 114 11/3/2026
11.0.2787 200 11/3/2026
11.0.2785 284 11/3/2026
11.0.2784 894 10/29/2026
11.0.2783 359 10/27/2026
11.0.2782 204 10/27/2026
11.0.2781 161 10/27/2026
Loading failed

Update dependency Soenneker.Cosmos.Database.Setup to 11.0.2460 (#3573)