Skip to content

Client

The client package registers ADO.NET clustering provider builders — resolved automatically from Aspire-injected configuration via [assembly: RegisterProvider] attributes. Use this in projects that need to call grains (e.g. an API gateway) but do not host grains themselves.

Call client.UseAdoNetClient() inside the UseOrleansClient lambda:

using Shiny.Aspire.Orleans.Client;
var builder = WebApplication.CreateBuilder(args);
builder.UseOrleansClient(client =>
{
client.UseAdoNetClient();
});
var app = builder.Build();
app.MapGet("/counter/{name}", async (string name, IClusterClient client) =>
{
var grain = client.GetGrain<ICounterGrain>(name);
var count = await grain.GetCount();
return Results.Ok(new { name, count });
});
app.Run();
public static IClientBuilder UseAdoNetClient(this IClientBuilder clientBuilder)

Marker extension for discoverability. Registers ADO.NET clustering provider builders for both Silo and Client targets. Unlike the server package, the client only needs clustering configuration to discover and connect to silos.

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

Orleans:Clustering:ProviderType = "PostgresDatabase"
Orleans:Clustering:ServiceKey = "orleans-db"
ConnectionStrings:orleans-db = "Host=...;Database=..."
builder.AddProject<Projects.MyApi>("api")
.WithReference(orleans.AsClient())
.WaitFor(db);

Note the use of .AsClient() which provides only the clustering configuration needed for client connectivity.