Events
Mar 17, 11 PM - Mar 21, 11 PM
Join the meetup series to build scalable AI solutions based on real-world use cases with fellow developers and experts.
Register nowThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
A client for connecting to a cluster of silos and sending requests to grains is configured programmatically via an IHostBuilder and several supplemental option classes. Like silo options, client option classes follow the Options pattern in .NET.
A client for connecting to a cluster of silos and sending requests to grains is configured programmatically via an ClientBuilder and several supplemental option classes. Like silo options, client option classes follow the Options pattern in .NET.
Tip
If you just want to start a local silo and a local client for development purposes, see Local development configuration.
Add the Microsoft.Orleans.Clustering.AzureStorage NuGet package to the client project.
There are several key aspects of client configuration:
Example of a client configuration:
var client = new HostBuilder()
.UseOrleansClient((context, clientBuilder) =>
{
clientBuilder.Configure<ClusterOptions>(options =>
{
options.ClusterId = "my-first-cluster";
options.ServiceId = "MyOrleansService";
})
.UseAzureStorageClustering(
options => options.ConfigureTableServiceClient(
context.Configuration["ORLEANS_AZURE_STORAGE_CONNECTION_STRING"]));
})
.Build();
using Orleans.Hosting;
var client = new ClientBuilder()
.Configure<ClusterOptions>(options =>
{
options.ClusterId = "my-first-cluster";
options.ServiceId = "MyOrleansService";
})
.UseAzureStorageClustering(
options => options.ConnectionString = connectionString)
.ConfigureApplicationParts(
parts => parts.AddApplicationPart(
typeof(IValueGrain).Assembly))
.Build();
Let's breakdown the steps used in this sample:
.Configure<ClusterOptions>(options =>
{
options.ClusterId = "orleans-docker";
options.ServiceId = "AspNetSampleApp";
})
Here we set two things:
"my-first-cluster"
: this is a unique ID for the Orleans cluster. All clients and silo that uses this ID will be able to directly talk to each other. Some will choose to use a different ClusterId
for each deployments for example."AspNetSampleApp"
: this is a unique ID for your application, that will be used by some provider (for example for persistence providers). This ID should be stable (not change) across deployments..UseAzureStorageClustering(
options => options.ConfigureTableServiceClient(connectionString);
.UseAzureStorageClustering(
options => options.ConnectionString = connectionString)
The client will discover all gateway available in the cluster using this provider. Several providers are available, here in this sample we use the Azure Table provider.
For more information, see Server configuration.
.ConfigureApplicationParts(
parts => parts.AddApplicationPart(
typeof(IValueGrain).Assembly))
.WithReferences())
For more information, see Server configuration.
.NET feedback
.NET is an open source project. Select a link to provide feedback:
Events
Mar 17, 11 PM - Mar 21, 11 PM
Join the meetup series to build scalable AI solutions based on real-world use cases with fellow developers and experts.
Register nowTraining
Module
Build your first Orleans app with ASP.NET Core 8.0 - Training
Learn how to build cloud-native, distributed apps with Orleans.