Soenneker.Cosmos.Container.Setup
11.0.2544
Prefix Reserved
dotnet add package Soenneker.Cosmos.Container.Setup --version 11.0.2544
NuGet\Install-Package Soenneker.Cosmos.Container.Setup -Version 11.0.2544
<PackageReference Include="Soenneker.Cosmos.Container.Setup" Version="11.0.2544" />
<PackageVersion Include="Soenneker.Cosmos.Container.Setup" Version="11.0.2544" />
<PackageReference Include="Soenneker.Cosmos.Container.Setup" />
paket add Soenneker.Cosmos.Container.Setup --version 11.0.2544
#r "nuget: Soenneker.Cosmos.Container.Setup, 11.0.2544"
#:package Soenneker.Cosmos.Container.Setup@11.0.2544
#addin nuget:?package=Soenneker.Cosmos.Container.Setup&version=11.0.2544
#tool nuget:?package=Soenneker.Cosmos.Container.Setup&version=11.0.2544
Soenneker.Cosmos.Container.Setup
Ensures an Azure Cosmos DB container exists with the package's standard partition key path.
Install
dotnet add package Soenneker.Cosmos.Container.Setup
Registration
using Soenneker.Cosmos.Container.Setup.Registrars;
services.AddCosmosContainerSetupUtilAsSingleton();
Use AddCosmosContainerSetupUtilAsScoped() when the setup service should follow a dependency-injection scope. Its Cosmos database dependency remains a long-lived singleton.
Usage
Use configured Cosmos credentials and the configured default database:
using Microsoft.Azure.Cosmos;
using Soenneker.Cosmos.Container.Setup.Abstract;
ContainerResponse? response = await setup.Ensure("orders", cancellationToken);
Or target an explicit account and database:
ContainerResponse? response = await setup.Ensure(
endpoint,
accountKey,
databaseName,
containerName,
cancellationToken);
An overload also accepts an existing Microsoft.Azure.Cosmos.Database handle.
Provisioning behavior
- Containers are created with partition key path
/partitionKey. The path is case-sensitive and must match the serialized document property exactly. - No dedicated container throughput is configured; the service uses the database/account throughput behavior.
- Existing containers are returned by
CreateIfNotExistsAsync; the utility does not reconcile partition keys, indexing policies, throughput, or other settings on an existing container. - Transient Cosmos, HTTP, and timeout failures are retried up to five times with exponential delay and jitter. Authentication, authorization, and other non-transient Cosmos errors fail immediately.
- Cancellation stops the active SDK call and retry delays. After retries are exhausted, the final exception propagates to the caller.
ContainerInfo is a public metadata DTO for a container name, partition-key path, and composite indexes. The current Ensure methods do not consume it and always use /partitionKey with the SDK's default indexing policy.
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 | net11.0 is compatible. |
-
net11.0
- Soenneker.Cosmos.Database (>= 11.0.2803)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Soenneker.Cosmos.Container.Setup:
| Package | Downloads |
|---|---|
|
Soenneker.Cosmos.Container
A utility library for storing Azure Cosmos containers |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 11.0.2544 | 0 | 11/15/2026 |
| 11.0.2543 | 42 | 11/14/2026 |
| 11.0.2542 | 254 | 11/12/2026 |
| 11.0.2541 | 116 | 11/11/2026 |
| 11.0.2540 | 126 | 11/11/2026 |
| 11.0.2539 | 83 | 11/11/2026 |
| 11.0.2538 | 124 | 11/11/2026 |
| 11.0.2537 | 171 | 11/11/2026 |
| 11.0.2536 | 65 | 11/11/2026 |
| 11.0.2535 | 169 | 11/11/2026 |
| 11.0.2534 | 83 | 11/11/2026 |
| 11.0.2533 | 662 | 11/7/2026 |
| 11.0.2532 | 248 | 11/7/2026 |
| 11.0.2531 | 588 | 11/3/2026 |
| 11.0.2530 | 98 | 11/3/2026 |
| 11.0.2529 | 189 | 11/3/2026 |
| 11.0.2528 | 273 | 11/3/2026 |
| 11.0.2527 | 878 | 10/29/2026 |
| 11.0.2526 | 351 | 10/27/2026 |
| 11.0.2525 | 189 | 10/27/2026 |
Update dependency Soenneker.Cosmos.Database to 11.0.2803 (#3268)