Cirreum.Persistence.Azure 1.0.31

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

Cirreum.Persistence.Azure

NuGet Version NuGet Downloads GitHub Release License .NET

Enterprise-grade Azure Cosmos DB persistence layer for .NET applications

Overview

Cirreum.Persistence.Azure provides a production-ready persistence layer for Azure Cosmos DB with NoSQL support. Built on the repository pattern, it seamlessly integrates with the Cirreum Foundation Framework to deliver consistent, scalable data access patterns.

Key Features

  • Repository Pattern Implementation - Clean abstraction over Azure Cosmos DB operations
  • Multi-Instance Support - Keyed service registration for multiple database connections
  • In-Memory Testing - Built-in in-memory repository for unit testing
  • Health Checks - Native ASP.NET Core health check integration
  • Performance Optimized - Bandwidth optimization and efficient query processing
  • Security Integrated - User context tracking and Azure Identity support
  • Strongly Typed - Full generic support with compile-time type safety

Quick Start

// Program.cs - Register with IHostApplicationBuilder
builder.AddCosmosDb("default", settings => {
    settings.ConnectionString = "AccountEndpoint=https://...;AccountKey=...";
    settings.DatabaseId = "MyDatabase";
    settings.OptimizeBandwidth = true;
});

// Inject and use repository
public class UserService
{
    private readonly IRepository<User> _userRepository;

    public UserService([FromKeyedServices("default")] IRepository<User> userRepository)
    {
        _userRepository = userRepository;
    }

    public async Task<User?> GetUserAsync(string id, CancellationToken ct)
    {
        return await _userRepository.GetAsync(id, cancellationToken: ct);
    }
}

Configuration

Programmatic Configuration

// Simple connection string
builder.AddCosmosDb("default", "AccountEndpoint=https://...;AccountKey=...");

// Full configuration
builder.AddCosmosDb("default", settings => {
    settings.ConnectionString = "AccountEndpoint=https://...;AccountKey=...";
    settings.DatabaseId = "MyDatabase";
    settings.ApplicationName = "MyApp";
    settings.OptimizeBandwidth = true;
    settings.AllowBulkExecution = false;
    settings.IsAutoResourceCreationEnabled = true;
}, clientOptions => {
    clientOptions.ConnectionMode = ConnectionMode.Direct;
}, healthOptions => {
    healthOptions.ContainerIds = ["users", "orders"];
});

Multiple Database Instances

// Register multiple databases with keyed services
builder.AddCosmosDb("primary", "AccountEndpoint=https://primary.documents.azure.com;AccountKey=...");
builder.AddCosmosDb("analytics", "AccountEndpoint=https://analytics.documents.azure.com;AccountKey=...");

// Inject specific instance
public class AnalyticsService([FromKeyedServices("analytics")] IRepository<Event> repository)
{
    // Uses the analytics database connection
}

appsettings.json Configuration

{
  "ServiceProviders": {
    "Persistence": {
      "Azure": {
        "default": {
          "Name": "MyCosmosDb",
          "DatabaseId": "MyDatabase",
          "ApplicationName": "MyApp",
          "OptimizeBandwidth": true,
          "AllowBulkExecution": false,
          "IsAutoResourceCreationEnabled": true,
          "HealthOptions": {
            "ContainerIds": ["users", "orders"]
          }
        }
      }
    }
  }
}

The Name property is used to resolve the connection string via Configuration.GetConnectionString(name). For production, store connection strings in Azure Key Vault using the naming convention ConnectionStrings--{Name} (e.g., ConnectionStrings--MyCosmosDb).

In-Memory Testing

For unit testing, use the built-in in-memory repository:

// Register in-memory repository for testing
services.AddInMemoryCosmosRepository("test");

// Inject in tests
public class UserServiceTests
{
    private readonly IRepository<User> _repository;

    public UserServiceTests([FromKeyedServices("test")] IRepository<User> repository)
    {
        _repository = repository;
    }
}

Contribution Guidelines

  1. Be conservative with new abstractions
    The API surface must remain stable and meaningful.

  2. Limit dependency expansion
    Only add foundational, version-stable dependencies.

  3. Favor additive, non-breaking changes
    Breaking changes ripple through the entire ecosystem.

  4. Include thorough unit tests
    All primitives and patterns should be independently testable.

  5. Document architectural decisions
    Context and reasoning should be clear for future maintainers.

  6. Follow .NET conventions
    Use established patterns from Microsoft.Extensions.* libraries.

Versioning

Cirreum.Persistence.Azure follows Semantic Versioning:

  • Major - Breaking API changes
  • Minor - New features, backward compatible
  • Patch - Bug fixes, backward compatible

Given its foundational role, major version bumps are rare and carefully considered.

License

This project is licensed under the MIT License - see the LICENSE file for details.


Cirreum Foundation Framework
Layered simplicity for modern .NET

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 (2)

Showing the top 2 NuGet packages that depend on Cirreum.Persistence.Azure:

Package Downloads
Cirreum.Runtime.Persistence

The Runtime Persistence service configuration.

Cirreum.Runtime.Persistence.Azure

The Runtime Persistence service configuration for Azure.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.31 34 3/4/2026
1.0.30 129 2/5/2026
1.0.29 117 1/23/2026
1.0.28 98 1/22/2026
1.0.27 115 1/21/2026
1.0.26 120 1/12/2026
1.0.25 119 1/11/2026
1.0.24 118 1/5/2026
1.0.23 104 1/5/2026
1.0.22 136 1/2/2026
1.0.21 116 1/1/2026
1.0.20 116 12/30/2025
1.0.19 106 12/29/2025
1.0.18 103 12/29/2025
1.0.17 95 12/29/2025
1.0.16 104 12/29/2025
1.0.15 196 12/22/2025
1.0.14 121 12/20/2025
1.0.12 267 12/19/2025
1.0.11 255 12/19/2025
Loading failed