title: Client Configuration

[!NOTE] If you just want to start a local silo and a local client for development purpose, look at the Local Development Configuration page.

Client Configuration

A client for connecting to a cluster of silos and sending requests to grains is configured programmatically via a ClientBuilder and a number of supplemental option classes. Like silo options, client option classes follow the ASP.NET Options.

Add the Microsoft.Orleans.Clustering.AzureStorage nuget package to the client project.

There are several key aspects of client configuration:

  • Orleans clustering information
  • Clustering provider
  • Application parts

Example of a client configuration:

  1. using Orleans.Hosting;
  2. var client = new ClientBuilder()
  3. // Clustering information
  4. .Configure<ClusterOptions>(options =>
  5. {
  6. options.ClusterId = "my-first-cluster";
  7. options.ServiceId = "MyOrleansService";
  8. })
  9. // Clustering provider
  10. .UseAzureStorageClustering(options => options.ConnectionString = connectionString)
  11. // Application parts: just reference one of the grain interfaces that we use
  12. .ConfigureApplicationParts(parts => parts.AddApplicationPart(typeof(IValueGrain).Assembly))
  13. .Build();

Let’s breakdown the steps used in this sample:

Orleans clustering information

  1. [...]
  2. // Clustering information
  3. .Configure<ClusterOptions>(options =>
  4. {
  5. options.ClusterId = "orleans-docker";
  6. options.ServiceId = "AspNetSampleApp";
  7. })
  8. [...]

Here we set two things:

  • the ClusterId to "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.
  • the ServiceId to "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.

Clustering provider

  1. [...]
  2. // Clustering provider
  3. .UseAzureStorageClustering(options => options.ConnectionString = connectionString)
  4. [...]

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.

To get more detail, look in the matching section in the Server Configuration page.

Application parts

  1. [...]
  2. // Application parts: just reference one of the grain interfaces that we use
  3. .ConfigureApplicationParts(parts => parts.AddApplicationPart(typeof(IValueGrain).Assembly)).WithReferences())
  4. [...];

To get more detail, look in the matching section in the Server Configuration page.