Excalibur.EventSourcing.CosmosDb 3.0.0-alpha.26

This is a prerelease version of Excalibur.EventSourcing.CosmosDb.
dotnet add package Excalibur.EventSourcing.CosmosDb --version 3.0.0-alpha.26
                    
NuGet\Install-Package Excalibur.EventSourcing.CosmosDb -Version 3.0.0-alpha.26
                    
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="Excalibur.EventSourcing.CosmosDb" Version="3.0.0-alpha.26" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Excalibur.EventSourcing.CosmosDb" Version="3.0.0-alpha.26" />
                    
Directory.Packages.props
<PackageReference Include="Excalibur.EventSourcing.CosmosDb" />
                    
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 Excalibur.EventSourcing.CosmosDb --version 3.0.0-alpha.26
                    
#r "nuget: Excalibur.EventSourcing.CosmosDb, 3.0.0-alpha.26"
                    
#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 Excalibur.EventSourcing.CosmosDb@3.0.0-alpha.26
                    
#: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=Excalibur.EventSourcing.CosmosDb&version=3.0.0-alpha.26&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Excalibur.EventSourcing.CosmosDb&version=3.0.0-alpha.26&prerelease
                    
Install as a Cake Tool

Excalibur.EventSourcing.CosmosDb

Azure Cosmos DB event store implementation for Excalibur event sourcing.

Features

  • Partition-aware event storage using {aggregateType}:{aggregateId} as partition key
  • Transactional batch support for atomic event appending
  • Change feed integration for event streaming
  • Optimistic concurrency with version-based conflict detection
  • Auto-provisioning of containers with configurable throughput

Installation

dotnet add package Excalibur.EventSourcing.CosmosDb

Configuration

services.AddCosmosDbEventStore(options =>
{
    options.EventsContainerName = "events";
    options.PartitionKeyPath = "/streamId";
    options.UseTransactionalBatch = true;
    options.MaxBatchSize = 100;
    options.ChangeFeedPollIntervalMs = 1000;
    options.CreateContainerIfNotExists = true;
    options.ContainerThroughput = 400;
});

Or via configuration:

services.AddCosmosDbEventStore(configuration.GetSection("CosmosDbEventStore"));

Usage

The package registers both IEventStore and ICloudNativeEventStore:

public class MyService
{
    private readonly IEventStore _eventStore;

    public MyService(IEventStore eventStore)
    {
        _eventStore = eventStore;
    }

    public async Task AppendEventsAsync(
        string aggregateId,
        IEnumerable<IDomainEvent> events,
        long expectedVersion,
        CancellationToken ct)
    {
        var result = await _eventStore.AppendEventsAsync(
            aggregateId,
            "MyAggregate",
            events.ToList(),
            expectedVersion,
            ct);

        if (!result.Success)
        {
            // Handle concurrency conflict or failure
        }
    }
}

Cloud-Native Features

For partition-aware operations, use ICloudNativeEventStore:

public class CloudNativeService
{
    private readonly ICloudNativeEventStore _eventStore;

    public CloudNativeService(ICloudNativeEventStore eventStore)
    {
        _eventStore = eventStore;
    }

    public async Task LoadWithPartitionAsync(CancellationToken ct)
    {
        var partition = new PartitionKey("MyAggregate", "aggregate-123");
        var result = await _eventStore.LoadEventsAsync(partition, 0, ct);
        // Process events...
    }
}

Change Feed Subscription

Subscribe to event changes for projections or other event handlers:

await using var subscription = await _eventStore.SubscribeToChangesAsync(ct);
await subscription.StartAsync(ct);

await foreach (var change in subscription.ReadChangesAsync(ct))
{
    // Process event change
    Console.WriteLine($"Event: {change.Document?.EventType}");
}

Requirements

  • .NET 9.0+
  • Azure Cosmos DB account
  • Excalibur.Data.CosmosDb for connection management

License

See LICENSE files in repository root.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  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

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.0.0-alpha.26 33 3/5/2026
3.0.0-alpha.19 46 2/26/2026