Soenneker.Cosmos.Container 11.0.2625

Prefix Reserved
dotnet add package Soenneker.Cosmos.Container --version 11.0.2625
                    
NuGet\Install-Package Soenneker.Cosmos.Container -Version 11.0.2625
                    
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.Container" Version="11.0.2625" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Soenneker.Cosmos.Container" Version="11.0.2625" />
                    
Directory.Packages.props
<PackageReference Include="Soenneker.Cosmos.Container" />
                    
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.Container --version 11.0.2625
                    
#r "nuget: Soenneker.Cosmos.Container, 11.0.2625"
                    
#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.Container@11.0.2625
                    
#: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.Container&version=11.0.2625
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.Cosmos.Container&version=11.0.2625
                    
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.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

  • Delete and DeleteAll permanently remove Cosmos resources and their data. Scope credentials narrowly and do not expose these methods directly to untrusted input.
  • Delete obtains 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 Container handles. 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 Compatible and additional computed target framework versions.
.NET net11.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
11.0.2625 151 11/7/2026
11.0.2624 142 11/7/2026
11.0.2623 459 11/3/2026
11.0.2622 78 11/3/2026
11.0.2621 154 11/3/2026
11.0.2620 232 11/3/2026
11.0.2619 827 10/29/2026
11.0.2618 332 10/27/2026
11.0.2617 198 10/27/2026
11.0.2616 133 10/27/2026
11.0.2615 159 10/27/2026
11.0.2614 149 10/27/2026
11.0.2613 313 10/27/2026
11.0.2612 187 10/27/2026
11.0.2611 204 10/27/2026
11.0.2610 157 10/27/2026
11.0.2608 180 10/26/2026
11.0.2606 273 10/26/2026
11.0.2605 234 10/26/2026
4.0.2604 871 10/15/2026
Loading failed

Update dependency Soenneker.Cosmos.Container.Setup to 11.0.2533 (#3484)