Skip to content

Latest commit

 

History

History
26 lines (22 loc) · 875 Bytes

CosmosDBSetup.md

File metadata and controls

26 lines (22 loc) · 875 Bytes

Setup CosmosDB event store

  1. Install NuGet package JKang.EventSourcing.Persistence.CosmosDB

    PM> Install-Package JKang.EventSourcing.Persistence.CosmosDB
  2. Register event sourcing services in ConfigureServices()

    services
        .AddSingleton(_ =>
            new CosmosClientBuilder(Configuration.GetConnectionString("CosmosDB"))
                .WithConnectionModeDirect()
                .WithCustomSerializer(new EventSourcingCosmosSerializer())
                .Build())
        .AddEventSourcing(builder =>
        {
            builder.UseCosmosDBEventStore<GiftCard, Guid>(x =>
            {
                x.DatabaseId = "EventSourcingTestingWebApp";
                x.ContainerId = "GiftcardEvents";
            });
        });