Soenneker.Cosmos.Container
4.0.2500
Prefix Reserved
See the version list below for details.
dotnet add package Soenneker.Cosmos.Container --version 4.0.2500
NuGet\Install-Package Soenneker.Cosmos.Container -Version 4.0.2500
<PackageReference Include="Soenneker.Cosmos.Container" Version="4.0.2500" />
<PackageVersion Include="Soenneker.Cosmos.Container" Version="4.0.2500" />
<PackageReference Include="Soenneker.Cosmos.Container" />
paket add Soenneker.Cosmos.Container --version 4.0.2500
#r "nuget: Soenneker.Cosmos.Container, 4.0.2500"
#:package Soenneker.Cosmos.Container@4.0.2500
#addin nuget:?package=Soenneker.Cosmos.Container&version=4.0.2500
#tool nuget:?package=Soenneker.Cosmos.Container&version=4.0.2500
Soenneker.Cosmos.Container
Provides cached Azure Cosmos DB container handles plus list and delete operations.
Install
dotnet add package Soenneker.Cosmos.Container
Configuration
{
"Azure": {
"Cosmos": {
"Endpoint": "https://your-account.documents.azure.com:443/",
"AccountKey": "your-account-key",
"DatabaseName": "application",
"EnsureContainerOnFirstUse": true
}
}
}
EnsureContainerOnFirstUse defaults to true. On the first Get for a container, the setup utility attempts to create it with partition key path /partitionKey before returning the SDK handle. Set it to false when infrastructure provisioning owns container creation or your containers use another partition key path.
Registration
using Soenneker.Cosmos.Container.Registrars;
services.AddCosmosContainerUtilAsSingleton();
The registration includes the client, database, and container-setup dependencies and intentionally uses a singleton lifetime.
Get a container
using Microsoft.Azure.Cosmos;
using Soenneker.Cosmos.Container.Abstract;
public sealed class OrderStore(ICosmosContainerUtil containers)
{
public ValueTask<Container> Get(CancellationToken cancellationToken)
{
return containers.Get("orders", cancellationToken);
}
}
Use the explicit overload for another account or database:
Container container = await containers.Get(
endpoint,
accountKey,
databaseName,
containerName,
cancellationToken);
Handles are cached by endpoint, a SHA-256 identity of the account key, database name, and container name. A rotated account key therefore receives a handle backed by the correct client without putting the raw key into the cache key.
List and delete
IReadOnlyList<ContainerProperties> existing = await containers.GetAll(cancellationToken);
await containers.Delete("obsolete", cancellationToken);
GetAll follows every Cosmos feed page and buffers all ContainerProperties in a list. DeleteAll lists the database and then deletes each container sequentially.
Operational notes
DeleteandDeleteAllpermanently remove Cosmos resources and their data. Scope credentials narrowly and do not expose these methods directly to untrusted input.Deleteobtains the cached handle before issuing the service deletion, then evicts that handle after success. A failed service deletion remains cached and the exception propagates.- Do not dispose returned
Containerhandles. The singleton utilities own the underlying clients and caches. - Account keys are credentials. Store them in a secret provider and keep them out of logs and source control.
| 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.Container.Setup (>= 4.0.2414)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Soenneker.Cosmos.Container:
| Package | Downloads |
|---|---|
|
Soenneker.Cosmos.Repository
A data persistence abstraction layer for Cosmos DB |
|
|
Soenneker.Cosmos.Suite
A concoction of Azure Cosmos utilities and libraries |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 4.0.2503 | 0 | 8/31/2026 |
| 4.0.2502 | 10 | 8/30/2026 |
| 4.0.2501 | 118 | 8/30/2026 |
| 4.0.2500 | 44 | 8/30/2026 |
| 4.0.2499 | 44 | 8/30/2026 |
| 4.0.2498 | 104 | 8/30/2026 |
| 4.0.2497 | 47 | 8/30/2026 |
| 4.0.2496 | 78 | 8/29/2026 |
| 4.0.2495 | 38 | 8/29/2026 |
| 4.0.2494 | 328 | 8/27/2026 |
| 4.0.2493 | 175 | 8/26/2026 |
| 4.0.2492 | 130 | 8/26/2026 |
| 4.0.2491 | 392 | 8/22/2026 |
| 4.0.2490 | 210 | 8/22/2026 |
| 4.0.2489 | 295 | 8/21/2026 |
| 4.0.2488 | 581 | 8/19/2026 |
| 4.0.2487 | 256 | 8/18/2026 |
| 4.0.2486 | 250 | 8/18/2026 |
| 4.0.2485 | 421 | 8/14/2026 |
| 4.0.2484 | 184 | 8/13/2026 |
Update dependency Soenneker.Cosmos.Container.Setup to 4.0.2414 (#3332)