tasks Package

Contains the definitions for the functions that enable scheduling of activities.

Modules

call_http
continue_as_new
new_uuid
task_all
task_any
call_activity
call_activity_with_retry
call_http
call_suborchestrator
call_suborchestrator_with_retry
continue_as_new
create_timer
new_uuid
task_all
task_any
task_utilities
timer_task
wait_for_external_event

Functions

call_activity_task

Determine the state of Scheduling an activity for execution.

call_activity_task(state: List[azure.durable_functions.models.history.HistoryEvent.HistoryEvent], name: str, input_: Optional[Any] = None) -> azure.durable_functions.models.Task.Task

Parameters

state
<xref:List>[HistoryEvent]
Required

The list of history events to search to determine the current state of the activity.

name
str
Required

The name of the activity function to schedule.

input
<xref:Any>
default value: None

The JSON-serializable input to pass to the activity function.

Returns

A Durable Task that completes when the called activity function completes or fails.

Return type

call_activity_with_retry_task

Determine the state of scheduling an activity for execution with retry options.

call_activity_with_retry_task(state: List[azure.durable_functions.models.history.HistoryEvent.HistoryEvent], retry_options: azure.durable_functions.models.RetryOptions.RetryOptions, name: str, input_: Optional[Any] = None) -> azure.durable_functions.models.Task.Task

Parameters

state
<xref:List>[HistoryEvent]
Required

The list of history events to search to determine the current state of the activity.

retry_options
RetryOptions
Required

The retry options for the activity function.

name
str
Required

The name of the activity function to call.

input
<xref:Any>
default value: None

The JSON-serializable input to pass to the activity function.

Returns

A Durable Task that completes when the called activity function completes or fails completely.

Return type

call_http

Get task used to schedule a durable HTTP call to the specified endpoint.

call_http(state: List[azure.durable_functions.models.history.HistoryEvent.HistoryEvent], method: str, uri: str, content: Optional[str] = None, headers: Optional[Dict[str, str]] = None, token_source: Optional[azure.durable_functions.models.TokenSource.TokenSource] = None) -> azure.durable_functions.models.Task.Task

Parameters

state
<xref:List>[HistoryEvent]
Required

The list of events that have been processed to determine the state of the task to be scheduled

method
str
Required

The HTTP request method.

uri
str
Required

The HTTP request uri.

content
str
default value: None

The HTTP request content.

headers
<xref:Dict>[str, str]
default value: None

The HTTP request headers.

token_source
TokenSource
default value: None

The source of OAuth token to add to the request.

Returns

The durable HTTP request to schedule.

Return type

call_sub_orchestrator_task

Determine the state of Scheduling a sub-orchestrator for execution.

call_sub_orchestrator_task(context, state: List[azure.durable_functions.models.history.HistoryEvent.HistoryEvent], name: str, input_: Optional[Any] = None, instance_id: Optional[str] = None) -> azure.durable_functions.models.Task.Task

Parameters

context
<xref:<xref:'DurableOrchestrationContext':>>
Required

A reference to the orchestration context.

state
<xref:List>[HistoryEvent]
Required

The list of history events to search to determine the current state of the activity.

name
str
Required

The name of the activity function to schedule.

input
<xref:Optional>[<xref:Any>]
default value: None

The JSON-serializable input to pass to the activity function. Defaults to None.

instance_id
str
default value: None

The instance ID of the sub-orchestrator to call. Defaults to "".

Returns

A Durable Task that completes when the called sub-orchestrator completes or fails.

Return type

call_sub_orchestrator_with_retry_task

Determine the state of Scheduling a sub-orchestrator for execution, with retry options.

call_sub_orchestrator_with_retry_task(context, state: List[azure.durable_functions.models.history.HistoryEvent.HistoryEvent], retry_options: azure.durable_functions.models.RetryOptions.RetryOptions, name: str, input_: Optional[Any] = None, instance_id: Optional[str] = None) -> azure.durable_functions.models.Task.Task

Parameters

context
<xref:<xref:'DurableOrchestrationContext':>>
Required

A reference to the orchestration context.

state
<xref:List>[HistoryEvent]
Required

The list of history events to search to determine the current state of the activity.

retry_options
RetryOptions
Required

The settings for retrying this sub-orchestrator in case of a failure.

name
str
Required

The name of the activity function to schedule.

input
<xref:Optional>[<xref:Any>]
default value: None

The JSON-serializable input to pass to the activity function. Defaults to None.

instance_id
str
default value: None

The instance ID of the sub-orchestrator to call. Defaults to "".

Returns

A Durable Task that completes when the called sub-orchestrator completes or fails.

Return type

continue_as_new

Create a new continue as new action.

continue_as_new(context, input_: Optional[Any] = None)

Parameters

input
<xref:Any>
Required

The JSON-serializable input to pass to the activity function.

input_
default value: None

create_timer_task

Durable Timers are used in orchestrator function to implement delays.

create_timer_task(state: List[azure.durable_functions.models.history.HistoryEvent.HistoryEvent], fire_at: datetime.datetime) -> azure.durable_functions.tasks.timer_task.TimerTask

Parameters

state
<xref:List>[HistoryEvent]
Required

The list of history events to search to determine the current state of the activity

fire_at
datetime
Required

The time interval to fire the timer trigger

Returns

A Durable Timer Task that schedules the timer to wake up the activity

Return type

new_uuid

Create a new UUID that is safe for replay within an orchestration or operation.

The default implementation of this method creates a name-based UUID using the algorithm from RFC 4122 §4.3. The name input used to generate this value is a combination of the orchestration instance ID and an internally managed sequence number.

new_uuid(context: DurableOrchestrationContext) -> str

Parameters

context
DurableOrchestrationContext
Required

Provides reference to the instance id, current_utc_datetime and a new_uuid_counter attribute that is combined together to form that name that is used for the V5 UUID.

Returns

New UUID that is safe for replay within an orchestration or operation.

Return type

str

should_suspend

Check the state of the result to determine if the orchestration should suspend.

should_suspend(partial_result) -> bool

Parameters

partial_result

task_all

Determine the state of scheduling the activities for execution with retry options.

task_all(tasks: List[azure.durable_functions.models.Task.Task])

Parameters

tasks
<xref:List>[Task]
Required

The tasks to evaluate their current state.

Returns

A Durable Task Set that reports the state of running all of the tasks within it.

Return type

task_any

Determine whether any of the given tasks is completed.

task_any(tasks)

Parameters

tasks
Task
Required

The tasks to evaluate their current state.

Returns

Returns a completed Durable Task Set if any of the tasks is completed. Returns a not completed Durable Task Set if none of the tasks are completed. Returns a faulted Taskset if all tasks are faulted

Return type

wait_for_external_event_task

Determine the state of a task that is waiting for an event to occur.

wait_for_external_event_task(state: List[azure.durable_functions.models.history.HistoryEvent.HistoryEvent], name: str) -> azure.durable_functions.models.Task.Task

Parameters

state
<xref:List>[HistoryEvent]
Required

The list of history events to search to determine the current

of the task.
<xref:state>
Required
name
str
Required

The event name of the event that the task is waiting for.

Returns

Returns a completed task if the expected event was raised. Returns a not completed task if the expected event has not occurred yet.

Return type

call_http

Get task used to schedule a durable HTTP call to the specified endpoint.

call_http(state: List[azure.durable_functions.models.history.HistoryEvent.HistoryEvent], method: str, uri: str, content: Optional[str] = None, headers: Optional[Dict[str, str]] = None, token_source: Optional[azure.durable_functions.models.TokenSource.TokenSource] = None) -> azure.durable_functions.models.Task.Task

Parameters

state
<xref:List>[HistoryEvent]
Required

The list of events that have been processed to determine the state of the task to be scheduled

method
str
Required

The HTTP request method.

uri
str
Required

The HTTP request uri.

content
str
default value: None

The HTTP request content.

headers
<xref:Dict>[str, str]
default value: None

The HTTP request headers.

token_source
TokenSource
default value: None

The source of OAuth token to add to the request.

Returns

The durable HTTP request to schedule.

Return type

continue_as_new

Create a new continue as new action.

continue_as_new(context, input_: Optional[Any] = None)

Parameters

input
<xref:Any>
Required

The JSON-serializable input to pass to the activity function.

input_
default value: None

new_uuid

Create a new UUID that is safe for replay within an orchestration or operation.

The default implementation of this method creates a name-based UUID using the algorithm from RFC 4122 §4.3. The name input used to generate this value is a combination of the orchestration instance ID and an internally managed sequence number.

new_uuid(context: DurableOrchestrationContext) -> str

Parameters

context
DurableOrchestrationContext
Required

Provides reference to the instance id, current_utc_datetime and a new_uuid_counter attribute that is combined together to form that name that is used for the V5 UUID.

Returns

New UUID that is safe for replay within an orchestration or operation.

Return type

str

task_all

Determine the state of scheduling the activities for execution with retry options.

task_all(tasks: List[azure.durable_functions.models.Task.Task])

Parameters

tasks
<xref:List>[Task]
Required

The tasks to evaluate their current state.

Returns

A Durable Task Set that reports the state of running all of the tasks within it.

Return type

task_any

Determine whether any of the given tasks is completed.

task_any(tasks)

Parameters

tasks
Task
Required

The tasks to evaluate their current state.

Returns

Returns a completed Durable Task Set if any of the tasks is completed. Returns a not completed Durable Task Set if none of the tasks are completed. Returns a faulted Taskset if all tasks are faulted

Return type