AddDurableHttpClient(IServiceCollection, string, Action<DurableHttpClientOptions>)
staticextension
public static IHttpClientBuilder AddDurableHttpClient(this IServiceCollection services, string name, Action<DurableHttpClientOptions>? configureOptions = null) Adds an
IDurableHttpClient, which durable tasks inject as a keyed service named name, and returns the builder of the named System.Net.Http.HttpClient which it sends requests with. Parameters
servicesIServiceCollection- The silo's service collection.
namestring- The client's name, which keys the service and names the
System.Net.Http.HttpClient. configureOptionsAction<DurableHttpClientOptions>- Configures the client, or
nullfor the defaults.
Returns
The builder of the named client, whose first handler is a
DurableIdempotencyKeyHandler, so handlers which the builder adds, such as a resilience handler, retry requests with their keys. Examples
services.AddDurableHttpClient("payments") .ConfigureHttpClient(client => client.BaseAddress = new("https://payments.example")) .AddStandardResilienceHandler();
public sealed class OrderGrain([FromKeyedServices("payments")] IDurableHttpClient payments) : DurableGrain, IOrderGrain