Soenneker.Cosmos.Database 4.0.2681

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package Soenneker.Cosmos.Database --version 4.0.2681
                    
NuGet\Install-Package Soenneker.Cosmos.Database -Version 4.0.2681
                    
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="4.0.2681" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Soenneker.Cosmos.Database" Version="4.0.2681" />
                    
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 4.0.2681
                    
#r "nuget: Soenneker.Cosmos.Database, 4.0.2681"
                    
#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@4.0.2681
                    
#: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=4.0.2681
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.Cosmos.Database&version=4.0.2681
                    
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 net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
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
4.0.2701 0 9/9/2026
4.0.2700 38 9/9/2026
4.0.2699 51 9/8/2026
4.0.2698 33 9/8/2026
4.0.2697 183 9/8/2026
4.0.2696 42 9/8/2026
4.0.2695 145 9/8/2026
4.0.2694 246 9/7/2026
4.0.2693 81 9/7/2026
4.0.2692 45 9/7/2026
4.0.2691 349 9/5/2026
4.0.2690 93 9/5/2026
4.0.2689 281 9/4/2026
4.0.2688 140 9/4/2026
4.0.2687 51 9/4/2026
4.0.2686 212 9/4/2026
4.0.2685 213 9/4/2026
4.0.2684 55 9/4/2026
4.0.2683 69 9/4/2026
4.0.2681 91 9/4/2026
Loading failed

Add interface inheritdoc references