Skip to main content
net10.0net8.0

Microsoft Orleans persistence providers backed by AWS DynamoDB

Published
Oct 3, 2026
18d ago
Total Downloads
906.1K
906,149

Install

dotnet add package Microsoft.Orleans.Persistence.DynamoDB --version 10.4.0
ProductVersions
.NET
net10.0net8.0

README

Microsoft Orleans Persistence for DynamoDB

Introduction

Microsoft Orleans Persistence for DynamoDB provides grain persistence for Microsoft Orleans using Amazon's DynamoDB. This allows your grains to persist their state in DynamoDB and reload it when they are reactivated.

Getting Started

To use this package, install it via NuGet:

dotnet add package Microsoft.Orleans.Persistence.DynamoDB

Example - Configuring DynamoDB Persistence

using Microsoft.Extensions.Hosting;
using Orleans.Configuration;
using Orleans.Hosting;

var builder = Host.CreateApplicationBuilder(args)
    .UseOrleans(siloBuilder =>
    {
        siloBuilder
            .UseLocalhostClustering()
            // Configure DynamoDB as grain storage
            .AddDynamoDBGrainStorage(
                name: "dynamoStore",
                configureOptions: options =>
                {
                    options.Service = "us-east-1";
                    options.TableName = "OrleansGrainState";
                    options.UseProvisionedThroughput = false;
                });
    });

// Run the host
await builder.RunAsync();

Endpoints and credentials

Service selects an AWS region or an HTTP/HTTPS endpoint URL. AccessKey and SecretKey supply explicit credentials; adding Token supplies session credentials. ProfileName selects a named AWS profile when explicit keys are omitted. These credentials apply to both regions and endpoint URLs.

The AWS SDK credential chain supplies credentials for regions and HTTPS endpoints when explicit keys and a profile are omitted. HTTP endpoints use the local-development credentials dummy and dummyKey in that case. Configure explicit credentials when a DynamoDB Local instance uses an access key to select its database.

Example - Using Grain Storage in a Grain

// Define grain state class

public class MyGrainState
{
    public string Data { get; set; }
    public int Version { get; set; }
}

// Grain implementation that uses the DynamoDB storage
public class MyGrain : Grain, IMyGrain, IGrainWithStringKey
{
    private readonly IPersistentState<MyGrainState> _state;

    public MyGrain([PersistentState("state", "dynamoStore")] IPersistentState<MyGrainState> state)
    {
        _state = state;
    }

    public async Task SetData(string data)
    {
        _state.State.Data = data;
        _state.State.Version++;
        await _state.WriteStateAsync();
    }

    public Task<string> GetData()
    {
        return Task.FromResult(_state.State.Data);
    }
}

Documentation

For more comprehensive documentation, please refer to:

Feedback & Contributing

Changes from Previous Version

No structural changes between v10.3.1 and v10.4.0.

Adoption Assessment

A verified publisher signal is available. Assess fit from the package's supported frameworks, license and dependency graph rather than popularity alone.

Compatibility metadata lists 2 target frameworks; confirm the exact target used by your application.The published metadata declares 55 direct dependency entries across framework groups. Inspect the resolved dependency graph for your target framework.

Related Guides & Workflows

Learn how to evaluate, integrate, or audit this package in your .NET project.