Microsoft.Orleans.Persistence.AzureStorage 9.2.1

Prefix Reserved
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package Microsoft.Orleans.Persistence.AzureStorage --version 9.2.1
                    
NuGet\Install-Package Microsoft.Orleans.Persistence.AzureStorage -Version 9.2.1
                    
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="Microsoft.Orleans.Persistence.AzureStorage" Version="9.2.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Microsoft.Orleans.Persistence.AzureStorage" Version="9.2.1" />
                    
Directory.Packages.props
<PackageReference Include="Microsoft.Orleans.Persistence.AzureStorage" />
                    
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 Microsoft.Orleans.Persistence.AzureStorage --version 9.2.1
                    
#r "nuget: Microsoft.Orleans.Persistence.AzureStorage, 9.2.1"
                    
#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 Microsoft.Orleans.Persistence.AzureStorage@9.2.1
                    
#: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=Microsoft.Orleans.Persistence.AzureStorage&version=9.2.1
                    
Install as a Cake Addin
#tool nuget:?package=Microsoft.Orleans.Persistence.AzureStorage&version=9.2.1
                    
Install as a Cake Tool

Microsoft Orleans Persistence for Azure Storage

Introduction

Microsoft Orleans Persistence for Azure Storage provides grain persistence for Microsoft Orleans using Azure Storage (Blob and Table). This allows your grains to persist their state in Azure Storage and reload it when they are reactivated.

Getting Started

To use this package, install it via NuGet:

dotnet add package Microsoft.Orleans.Persistence.AzureStorage

Example - Configuring Azure Storage Persistence

using Microsoft.Extensions.Hosting;
using Orleans.Configuration;
using Orleans.Hosting;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Threading.Tasks;

// Define grain interface
public interface IMyGrain : IGrainWithStringKey
{
    Task SetData(string data);
    Task<string> GetData();
}


var builder = Host.CreateApplicationBuilder(args)
    .UseOrleans(siloBuilder =>
    {
        siloBuilder
            .UseLocalhostClustering()
            // Configure Azure Table Storage as grain storage
            .AddAzureTableGrainStorage(
                name: "tableStore",
                configureOptions: options =>
                {
                    options.ConnectionString = "YOUR_AZURE_STORAGE_CONNECTION_STRING";
                })
            // Configure Azure Blob Storage as grain storage
            .AddAzureBlobGrainStorage(
                name: "blobStore",
                configureOptions: options =>
                {
                    options.ConnectionString = "YOUR_AZURE_STORAGE_CONNECTION_STRING";
                });
    });

var host = builder.Build();
await host.StartAsync();

// Get a reference to a grain and call it
var client = host.Services.GetRequiredService<IClusterClient>();
var grain = client.GetGrain<IMyGrain>("user123");
await grain.SetData("Hello from Azure Storage!");
var response = await grain.GetData();

// Print the result
Console.WriteLine($"Grain data: {response}");

// Keep the host running until the application is shut down
await host.WaitForShutdownAsync();

Example - Using Grain Storage in a Grain

using System;
using System.Threading.Tasks;
using Orleans;
using Orleans.Runtime;
namespace ExampleGrains;

// Define grain state class

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

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

    public MyGrain([PersistentState("state", "tableStore")] 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

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 was computed.  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 was computed.  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 (6)

Showing the top 5 NuGet packages that depend on Microsoft.Orleans.Persistence.AzureStorage:

Package Downloads
Blauhaus.Orleans

Package Description

Blauhaus.EVACS.Orleans

Package Description

Microsoft.Orleans.OrleansAzureUtils

Support library for hosting Orleans on Microsoft Azure.

Orleans.Contrib.UniversalSilo

This library provides primitives to set up a configurable, application-agnostic Orleans silo and clients. Use it with the Orleans.Contrib.UniversalSilo.Templates to get started with Orleans.

Nabs.Launchpad.Core.Silo

Package Description

GitHub repositories (7)

Showing the top 7 popular GitHub repositories that depend on Microsoft.Orleans.Persistence.AzureStorage:

Repository Stars
dotnet/aspire
Aspire is the tool for code-first, extensible, observable dev and deploy.
dotnet/samples
Sample code referenced by the .NET documentation
Dotnet-Boxed/Templates
.NET project templates with batteries included, providing the minimum amount of code required to get you going faster.
microsoft/dotnet-podcasts
.NET reference application shown at .NET Conf featuring ASP.NET Core, Blazor, .NET MAUI, Microservices, Orleans, Playwright, and more!
J-Tech-Japan/Sekiban
Sekiban - an Opinionated Event Sourcing and CQRS Framework using C#. It can store data into Azure Cosmos DB, AWS Dynamo DB or Postgres
Samsung/Tizen.NET
Welcome to Tizen .NET
ReubenBond/hanbaobao-web
Orleans sample application with Kubernetes hosting
Version Downloads Last Updated
10.0.0-rc.2 493 12/31/2025
9.2.1 131,293 7/16/2025
9.2.0 2,076 7/14/2025
9.2.0-preview3 737 6/10/2025
9.2.0-preview2 238 6/4/2025
9.2.0-preview1 5,955 4/4/2025
9.1.2 142,701 2/13/2025
9.0.1 39,319 11/23/2024
9.0.0 3,881 11/14/2024
8.2.0 163,528 7/12/2024
8.2.0-preview1 383 5/22/2024
8.1.0 121,476 4/17/2024
8.1.0-preview3 1,166 3/11/2024
8.1.0-preview2 268 2/23/2024
8.1.0-preview1 1,406 2/13/2024
8.0.0 51,215 1/5/2024
8.0.0-rc2 410 12/20/2023
8.0.0-rc1 409 12/4/2023
7.2.7 7,066 10/15/2024
7.2.6 11,925 3/9/2024
7.2.5 8,973 2/22/2024
7.2.4 29,976 12/2/2023
7.2.3 17,304 11/3/2023
7.2.2 9,906 10/16/2023
7.2.1 78,547 7/11/2023
7.2.0 3,230 7/7/2023
7.1.2 37,786 4/19/2023
7.1.1 20,093 3/23/2023
7.1.0 36,282 2/1/2023
7.0.0 20,011 11/8/2022
7.0.0-rc2 722 10/19/2022
4.0.0-preview2 4,219 8/4/2022
4.0.0-preview1 2,678 2/10/2022
3.8.0 3,059 5/6/2025
3.8.0-preview5 330 5/12/2025
3.8.0-preview3 285 4/8/2025
3.8.0-preview2 243 4/4/2025
3.8.0-preview1 276 3/31/2025
3.7.2 21,455 5/10/2024
3.7.1 70,952 5/27/2023
3.7.0 96,954 3/23/2023
3.6.5 618,330 8/15/2022
3.6.4 18,119 8/10/2022
3.6.3 40,782 8/4/2022
3.6.2 598,977 4/15/2022
3.6.1 20,633 4/5/2022
3.6.0 113,163 1/20/2022
3.5.1 94,166 11/8/2021
3.5.0 90,817 9/3/2021
3.4.4 2,118 10/4/2021
3.4.3 62,990 6/3/2021
3.4.2 50,185 4/5/2021
3.4.1 42,754 2/3/2021
3.4.0 16,707 1/6/2021
3.4.0-rc1 727 12/9/2020
3.3.0 37,866 9/9/2020
3.3.0-rc2 1,748 9/2/2020
3.3.0-rc1 759 8/19/2020
3.2.2 11,664 7/22/2020
3.2.1 5,211 7/2/2020
3.2.0 7,135 6/4/2020
3.2.0-rc2 933 5/20/2020
3.2.0-rc1 929 5/7/2020
3.1.7 6,354 5/19/2020
3.1.6 19,748 4/16/2020
3.1.5 1,347 4/9/2020
3.1.4 18,624 3/26/2020
3.1.3 6,170 3/16/2020
3.1.2 4,517 3/5/2020
3.1.0 2,967 2/23/2020
3.1.0-rc3 811 2/13/2020
3.1.0-rc2 831 2/12/2020
3.1.0-rc1 809 2/10/2020
3.0.2 19,343 12/12/2019
3.0.1 3,044 11/27/2019
3.0.0 8,084 10/24/2019
3.0.0-rc2 844 10/16/2019
3.0.0-rc1 857 10/9/2019
3.0.0-beta1 1,217 8/16/2019
2.4.5 5,978 12/29/2019
2.4.4 12,581 11/27/2019
2.4.3 12,764 10/10/2019
2.4.2 8,316 8/31/2019
2.4.1 4,892 8/14/2019
2.4.0 5,334 8/8/2019
2.3.6 24,367 7/24/2019
2.3.5 15,536 6/14/2019
2.3.4 3,960 6/4/2019
2.3.3 2,726 6/2/2019
2.3.2 4,484 5/9/2019
2.3.1 3,417 4/26/2019
2.3.0 10,662 3/20/2019
2.3.0-rc2 2,263 3/13/2019
2.3.0-rc1 2,180 3/4/2019
2.2.4 4,476 2/25/2019
2.2.3 4,408 1/17/2019
2.2.0 9,928 12/13/2018
2.2.0-rc1 2,345 12/4/2018
2.2.0-beta1 2,526 10/21/2018
2.1.2 15,382 10/11/2018
2.1.0 4,554 9/28/2018
2.1.0-rc2 2,952 9/21/2018
2.1.0-rc1 2,851 9/14/2018
2.1.0-beta1 7,723 8/27/2018
2.0.3 9,076 6/15/2018
2.0.0 16,213 3/28/2018
2.0.0-rc2 3,501 3/13/2018
2.0.0-rc1 4,476 2/26/2018
2.0.0-beta3 4,936 12/21/2017
2.0.0-beta2 3,393 12/11/2017