Language

ResilientTaskServiceCollectionExtensions Class

Definition

Registration entry points for the resilient-tasks feature. Hosted storage can be configured with an explicit credential and endpoint, or through configuration-bound ResilientTaskSettings on an IHostApplicationBuilder. Without an explicit endpoint, the hosted credential can also be supplied through AddResilientTasks(IServiceCollection, TokenCredential) or a registered TokenCredential service. Lease durations and retry/timeout defaults are configured per task rather than globally.

public static class ResilientTaskServiceCollectionExtensions
type ResilientTaskServiceCollectionExtensions = class
Public Module ResilientTaskServiceCollectionExtensions
Inheritance
ResilientTaskServiceCollectionExtensions

Methods

Name Description
AddResilientMultiTurnTask<TInput,TOutput,THandler>(IServiceCollection, String, Boolean, Action<TaskRegistrationOptions>)

Registers a multi-turn task whose handler and dependencies are resolved from a fresh dependency-injection scope for each execution attempt.

AddResilientMultiTurnTask<TInput,TOutput,THandler>(IServiceCollection, String, JsonTypeInfo<TInput>, Boolean, Action<TaskRegistrationOptions>)

Registers a multi-turn scoped task handler using source-generated input serialization metadata.

AddResilientMultiTurnTask<TInput,TOutput>(IServiceCollection, String, Func<TaskContext<TInput>,CancellationToken,Task<TOutput>>, Boolean, Action<TaskRegistrationOptions>)

Registers a multi-turn task (Python @multi_turn_task), optionally steerable, and returns a typed TaskDefinition<TInput,TOutput> handle bound to it. The handle is also registered as a keyed singleton service — keyed by name — so it can be resolved later with GetResilientTask<TInput,TOutput>(IServiceProvider, String). The first call to any AddResilientTask/AddResilientMultiTurnTask method registers the lazy resilient-task services if they are not already present; it does not enable them.

AddResilientMultiTurnTask<TInput,TOutput>(IServiceCollection, String, Func<TaskContext<TInput>,CancellationToken,Task<TOutput>>, JsonTypeInfo<TInput>, Boolean, Action<TaskRegistrationOptions>)

Registers a multi-turn task (optionally steerable) using a source-generated JsonTypeInfo<T> for the input type (Native-AOT / trimming-safe). The returned handle is also registered as a keyed singleton service, keyed by name.

AddResilientTask<TInput,TOutput,THandler>(IServiceCollection, String, Action<TaskRegistrationOptions>)

Registers a one-shot task whose handler and dependencies are resolved from a fresh dependency-injection scope for each execution attempt.

AddResilientTask<TInput,TOutput,THandler>(IServiceCollection, String, JsonTypeInfo<TInput>, Action<TaskRegistrationOptions>)

Registers a one-shot scoped task handler using source-generated input serialization metadata.

AddResilientTask<TInput,TOutput>(IServiceCollection, String, Func<TaskContext<TInput>, CancellationToken,Task<TOutput>>, Action<TaskRegistrationOptions>)

Registers a one-shot task (Python @task) and returns a typed TaskDefinition<TInput,TOutput> handle bound to it. The handle is also registered as a keyed singleton service — keyed by name — so it can be resolved later with GetResilientTask<TInput,TOutput>(IServiceProvider, String). The first call to any AddResilientTask/AddResilientMultiTurnTask method registers the lazy resilient-task services if they are not already present; it does not enable them.

AddResilientTask<TInput,TOutput>(IServiceCollection, String, Func<TaskContext<TInput>, CancellationToken,Task<TOutput>>, JsonTypeInfo<TInput>, Action<TaskRegistrationOptions>)

Registers a one-shot task using a source-generated JsonTypeInfo<T> for the input type, so the task input is serialized without runtime reflection (Native-AOT / trimming-safe). The returned handle is also registered as a keyed singleton service, keyed by name.

AddResilientTasks(IServiceCollection, TokenCredential)

Registers the lazy resilient-task services, optionally supplying the hosted-storage credential. Calling AddResilientTask/AddResilientMultiTurnTask directly also performs this setup on first use, but neither registration path enables execution or recovery. Call SetResilientTasksEnabled(IServiceCollection, Boolean) before host startup to opt in. This method only needs to be called explicitly to supply a hosted credential. The credential may be supplied before or after task registrations while composing the service collection. A TokenCredential registered directly in the service collection is also supported; when both forms are used they must resolve to the same instance.

Applies to