Client
The client package configures an Orleans client with ADO.NET clustering — resolved automatically from Aspire-injected configuration. Use this in projects that need to call grains (e.g. an API gateway) but do not host grains themselves.
using Shiny.Aspire.Orleans.Client;
var builder = WebApplication.CreateBuilder(args);builder.UseOrleansClientWithAdoNet();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();UseOrleansClientWithAdoNet
Section titled “UseOrleansClientWithAdoNet”public static IHostApplicationBuilder UseOrleansClientWithAdoNet( this IHostApplicationBuilder builder)Reads Aspire-injected configuration and configures the Orleans client with ADO.NET clustering. Unlike the server package, the client only needs clustering configuration to discover and connect to silos.
Configuration
Section titled “Configuration”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=..."AppHost Wiring
Section titled “AppHost Wiring”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.