Soenneker.Cosmos.Database
4.0.2692
Prefix Reserved
See the version list below for details.
dotnet add package Soenneker.Cosmos.Database --version 4.0.2692
NuGet\Install-Package Soenneker.Cosmos.Database -Version 4.0.2692
<PackageReference Include="Soenneker.Cosmos.Database" Version="4.0.2692" />
<PackageVersion Include="Soenneker.Cosmos.Database" Version="4.0.2692" />
<PackageReference Include="Soenneker.Cosmos.Database" />
paket add Soenneker.Cosmos.Database --version 4.0.2692
#r "nuget: Soenneker.Cosmos.Database, 4.0.2692"
#:package Soenneker.Cosmos.Database@4.0.2692
#addin nuget:?package=Soenneker.Cosmos.Database&version=4.0.2692
#tool nuget:?package=Soenneker.Cosmos.Database&version=4.0.2692
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 | Versions 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. |
-
net10.0
- Soenneker.Cosmos.Database.Setup (>= 4.0.2337)
- Soenneker.Hashing.Sha256 (>= 4.0.1)
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.2694 | 0 | 9/7/2026 |
| 4.0.2693 | 0 | 9/7/2026 |
| 4.0.2692 | 0 | 9/7/2026 |
| 4.0.2691 | 157 | 9/5/2026 |
| 4.0.2690 | 71 | 9/5/2026 |
| 4.0.2689 | 186 | 9/4/2026 |
| 4.0.2688 | 101 | 9/4/2026 |
| 4.0.2687 | 42 | 9/4/2026 |
| 4.0.2686 | 157 | 9/4/2026 |
| 4.0.2685 | 151 | 9/4/2026 |
| 4.0.2684 | 41 | 9/4/2026 |
| 4.0.2683 | 54 | 9/4/2026 |
| 4.0.2682 | 104 | 9/4/2026 |
| 4.0.2681 | 74 | 9/4/2026 |
| 4.0.2680 | 119 | 9/4/2026 |
| 4.0.2679 | 265 | 9/3/2026 |
| 4.0.2678 | 282 | 9/1/2026 |
| 4.0.2677 | 182 | 9/1/2026 |
| 4.0.2676 | 283 | 8/31/2026 |
| 4.0.2675 | 96 | 8/31/2026 |
Merge remote updates with performance improvements