ResilientTaskServiceCollectionExtensions.AddResilientTask Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
| Name | Description |
|---|---|
| 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 |
| 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 |
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.
public static Azure.AI.AgentServer.Core.Tasks.TaskDefinition<TInput,TOutput> AddResilientTask<TInput,TOutput,THandler>(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, string name, Action<Azure.AI.AgentServer.Core.Tasks.TaskRegistrationOptions>? configure = default) where THandler : class, Azure.AI.AgentServer.Core.Tasks.IResilientTaskHandler<TInput,TOutput>;
static member AddResilientTask : Microsoft.Extensions.DependencyInjection.IServiceCollection * string * Action<Azure.AI.AgentServer.Core.Tasks.TaskRegistrationOptions> -> Azure.AI.AgentServer.Core.Tasks.TaskDefinition<'Input, 'Output> (requires 'Handler : null and 'Handler :> Azure.AI.AgentServer.Core.Tasks.IResilientTaskHandler<'Input, 'Output>)
<Extension()>
Public Function AddResilientTask(Of TInput, TOutput, THandler) (services As IServiceCollection, name As String, Optional configure As Action(Of TaskRegistrationOptions) = Nothing) As TaskDefinition(Of TInput, TOutput)
Type Parameters
- TInput
The task input type.
- TOutput
The task output type.
- THandler
The scoped task handler type.
Parameters
- services
- IServiceCollection
The service collection.
- name
- String
The unique task name.
- configure
- Action<TaskRegistrationOptions>
An optional callback to configure per-task options.
Returns
A typed task definition for running the registered task.
Applies to
AddResilientTask<TInput,TOutput,THandler>(IServiceCollection, String, JsonTypeInfo<TInput>, Action<TaskRegistrationOptions>)
Registers a one-shot scoped task handler using source-generated input serialization metadata.
public static Azure.AI.AgentServer.Core.Tasks.TaskDefinition<TInput,TOutput> AddResilientTask<TInput,TOutput,THandler>(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, string name, System.Text.Json.Serialization.Metadata.JsonTypeInfo<TInput> inputTypeInfo, Action<Azure.AI.AgentServer.Core.Tasks.TaskRegistrationOptions>? configure = default) where THandler : class, Azure.AI.AgentServer.Core.Tasks.IResilientTaskHandler<TInput,TOutput>;
static member AddResilientTask : Microsoft.Extensions.DependencyInjection.IServiceCollection * string * System.Text.Json.Serialization.Metadata.JsonTypeInfo<'Input> * Action<Azure.AI.AgentServer.Core.Tasks.TaskRegistrationOptions> -> Azure.AI.AgentServer.Core.Tasks.TaskDefinition<'Input, 'Output> (requires 'Handler : null and 'Handler :> Azure.AI.AgentServer.Core.Tasks.IResilientTaskHandler<'Input, 'Output>)
<Extension()>
Public Function AddResilientTask(Of TInput, TOutput, THandler) (services As IServiceCollection, name As String, inputTypeInfo As JsonTypeInfo(Of TInput), Optional configure As Action(Of TaskRegistrationOptions) = Nothing) As TaskDefinition(Of TInput, TOutput)
Type Parameters
- TInput
The task input type.
- TOutput
The task output type.
- THandler
The scoped task handler type.
Parameters
- services
- IServiceCollection
The service collection.
- name
- String
The unique task name.
- inputTypeInfo
- JsonTypeInfo<TInput>
The source-generated serialization metadata for the input.
- configure
- Action<TaskRegistrationOptions>
An optional callback to configure per-task options.
Returns
A typed task definition for running the registered task.
Applies to
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.
public static Azure.AI.AgentServer.Core.Tasks.TaskDefinition<TInput,TOutput> AddResilientTask<TInput,TOutput>(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, string name, Func<Azure.AI.AgentServer.Core.Tasks.TaskContext<TInput>,System.Threading.CancellationToken,System.Threading.Tasks.Task<TOutput>> handler, Action<Azure.AI.AgentServer.Core.Tasks.TaskRegistrationOptions>? configure = default);
static member AddResilientTask : Microsoft.Extensions.DependencyInjection.IServiceCollection * string * Func<Azure.AI.AgentServer.Core.Tasks.TaskContext<'Input>, System.Threading.CancellationToken, System.Threading.Tasks.Task<'Output>> * Action<Azure.AI.AgentServer.Core.Tasks.TaskRegistrationOptions> -> Azure.AI.AgentServer.Core.Tasks.TaskDefinition<'Input, 'Output>
<Extension()>
Public Function AddResilientTask(Of TInput, TOutput) (services As IServiceCollection, name As String, handler As Func(Of TaskContext(Of TInput), CancellationToken, Task(Of TOutput)), Optional configure As Action(Of TaskRegistrationOptions) = Nothing) As TaskDefinition(Of TInput, TOutput)
Type Parameters
- TInput
The task input type.
- TOutput
The task output type.
Parameters
- services
- IServiceCollection
The service collection.
- name
- String
The unique task name.
- handler
- Func<TaskContext<TInput>,CancellationToken,Task<TOutput>>
The handler delegate.
- configure
- Action<TaskRegistrationOptions>
An optional callback to configure per-task options.
Returns
A typed TaskDefinition<TInput,TOutput> for running the registered task.
Applies to
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.
public static Azure.AI.AgentServer.Core.Tasks.TaskDefinition<TInput,TOutput> AddResilientTask<TInput,TOutput>(this Microsoft.Extensions.DependencyInjection.IServiceCollection services, string name, Func<Azure.AI.AgentServer.Core.Tasks.TaskContext<TInput>,System.Threading.CancellationToken,System.Threading.Tasks.Task<TOutput>> handler, System.Text.Json.Serialization.Metadata.JsonTypeInfo<TInput> inputTypeInfo, Action<Azure.AI.AgentServer.Core.Tasks.TaskRegistrationOptions>? configure = default);
static member AddResilientTask : Microsoft.Extensions.DependencyInjection.IServiceCollection * string * Func<Azure.AI.AgentServer.Core.Tasks.TaskContext<'Input>, System.Threading.CancellationToken, System.Threading.Tasks.Task<'Output>> * System.Text.Json.Serialization.Metadata.JsonTypeInfo<'Input> * Action<Azure.AI.AgentServer.Core.Tasks.TaskRegistrationOptions> -> Azure.AI.AgentServer.Core.Tasks.TaskDefinition<'Input, 'Output>
<Extension()>
Public Function AddResilientTask(Of TInput, TOutput) (services As IServiceCollection, name As String, handler As Func(Of TaskContext(Of TInput), CancellationToken, Task(Of TOutput)), inputTypeInfo As JsonTypeInfo(Of TInput), Optional configure As Action(Of TaskRegistrationOptions) = Nothing) As TaskDefinition(Of TInput, TOutput)
Type Parameters
- TInput
The task input type.
- TOutput
The task output type.
Parameters
- services
- IServiceCollection
The service collection.
- name
- String
The unique task name.
- handler
- Func<TaskContext<TInput>,CancellationToken,Task<TOutput>>
The handler delegate.
- inputTypeInfo
- JsonTypeInfo<TInput>
The source-generated serialization metadata for TInput.
- configure
- Action<TaskRegistrationOptions>
An optional callback to configure per-task options.
Returns
A typed TaskDefinition<TInput,TOutput> for running the registered task.