Soenneker.Cosmos.Database 4.0.2686

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.2686
                    
NuGet\Install-Package Soenneker.Cosmos.Database -Version 4.0.2686
                    
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.2686" />
                    
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.2686" />
                    
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.2686
                    
#r "nuget: Soenneker.Cosmos.Database, 4.0.2686"
                    
#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.2686
                    
#: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.2686
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.Cosmos.Database&version=4.0.2686
                    
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.2697 0 9/8/2026
4.0.2696 0 9/8/2026
4.0.2695 0 9/8/2026
4.0.2694 35 9/7/2026
4.0.2693 43 9/7/2026
4.0.2692 30 9/7/2026
4.0.2691 226 9/5/2026
4.0.2690 74 9/5/2026
4.0.2689 196 9/4/2026
4.0.2688 105 9/4/2026
4.0.2687 43 9/4/2026
4.0.2686 163 9/4/2026
4.0.2685 158 9/4/2026
4.0.2684 41 9/4/2026
4.0.2683 54 9/4/2026
4.0.2682 106 9/4/2026
4.0.2681 77 9/4/2026
4.0.2680 125 9/4/2026
4.0.2679 273 9/3/2026
4.0.2678 282 9/1/2026
Loading failed

Updated Multiple NuGet packages