Skip to content

Server (Silo)

The server package configures an Orleans silo with ADO.NET clustering, grain storage, and reminders — all resolved automatically from the configuration that Aspire injects.

using Shiny.Aspire.Orleans.Server;
var builder = WebApplication.CreateBuilder(args);
builder.UseOrleansWithAdoNet();
var app = builder.Build();
app.Run();
public static IHostApplicationBuilder UseOrleansWithAdoNet(
this IHostApplicationBuilder builder
)

Reads Aspire-injected configuration and configures the Orleans silo with the appropriate ADO.NET providers for:

  • Clustering — silo membership via Orleans:Clustering
  • Grain Storage — persistent state via Orleans:GrainStorage:{Name}
  • Reminders — timer reminders via Orleans:Reminders

Aspire automatically injects the following configuration when you use .WithReference(orleans) in the AppHost:

Orleans:Clustering:ProviderType = "PostgresDatabase"
Orleans:Clustering:ServiceKey = "orleans-db"
Orleans:GrainStorage:Default:ProviderType = "PostgresDatabase"
Orleans:GrainStorage:Default:ServiceKey = "orleans-db"
Orleans:Reminders:ProviderType = "PostgresDatabase"
Orleans:Reminders:ServiceKey = "orleans-db"
ConnectionStrings:orleans-db = "Host=...;Database=..."

UseOrleansWithAdoNet() reads these sections and configures Orleans with the matching ADO.NET providers (Npgsql, Microsoft.Data.SqlClient, or MySqlConnector).

The server package supports multiple named grain storage providers:

// AppHost
var orleans = builder.AddOrleans("cluster")
.WithClustering(db)
.WithGrainStorage("Default", db)
.WithGrainStorage("Archive", archiveDb)
.WithDatabaseSetup(db);
// Grain
public class MyGrain(
[PersistentState("state", "Default")] IPersistentState<MyState> state,
[PersistentState("archive", "Archive")] IPersistentState<ArchiveState> archive
) : Grain, IMyGrain { }

Each named storage provider reads its configuration from Orleans:GrainStorage:{Name}:ProviderType and Orleans:GrainStorage:{Name}:ServiceKey.