Language

ServiceCollectionExtensions.ConfigureDurableOptions Method

Definition

Configures durable agents and workflows, automatically registering orchestrations, activities, and agent entities.

public static Microsoft.Extensions.DependencyInjection.IServiceCollection ConfigureDurableOptions(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, Action<Microsoft.Agents.AI.DurableTask.DurableOptions> configure, Action<Microsoft.DurableTask.Worker.IDurableTaskWorkerBuilder>? workerBuilder = default, Action<Microsoft.DurableTask.Client.IDurableTaskClientBuilder>? clientBuilder = default);
static member ConfigureDurableOptions : Microsoft.Extensions.DependencyInjection.IServiceCollection * Action<Microsoft.Agents.AI.DurableTask.DurableOptions> * Action<Microsoft.DurableTask.Worker.IDurableTaskWorkerBuilder> * Action<Microsoft.DurableTask.Client.IDurableTaskClientBuilder> -> Microsoft.Extensions.DependencyInjection.IServiceCollection
<Extension()>
Public Function ConfigureDurableOptions (services As IServiceCollection, configure As Action(Of DurableOptions), Optional workerBuilder As Action(Of IDurableTaskWorkerBuilder) = Nothing, Optional clientBuilder As Action(Of IDurableTaskClientBuilder) = Nothing) As IServiceCollection

Parameters

services
IServiceCollection

The service collection to configure.

configure
Action<DurableOptions>

A delegate to configure the durable options for both agents and workflows.

workerBuilder
Action<IDurableTaskWorkerBuilder>

Optional delegate to configure the durable task worker.

clientBuilder
Action<IDurableTaskClientBuilder>

Optional delegate to configure the durable task client.

Returns

The service collection for chaining.

Examples

services.ConfigureDurableOptions(options =>
{
    // Register agents not part of workflows
    options.Agents.AddAIAgent(standaloneAgent);

    // Register workflows - agents in workflows are auto-registered
    options.Workflows.AddWorkflow(myWorkflow);
},
workerBuilder: builder => builder.UseDurableTaskScheduler(connectionString),
clientBuilder: builder => builder.UseDurableTaskScheduler(connectionString));

Remarks

This is the recommended entry point for configuring durable functionality. It provides unified configuration for both agents and workflows through a single DurableOptions instance, ensuring agents referenced in workflows are automatically registered.

Multiple calls to this method (or to ConfigureDurableAgents(IServiceCollection, Action<DurableAgentsOptions>, Action<IDurableTaskWorkerBuilder>, Action<IDurableTaskClientBuilder>) and ConfigureDurableWorkflows(IServiceCollection, Action<DurableWorkflowOptions>, Action<IDurableTaskWorkerBuilder>, Action<IDurableTaskClientBuilder>)) are supported and configurations are composed additively.

Applies to