DurableOrchestrationContext Class
Context of the durable orchestration execution.
Parameter data for orchestration bindings that can be used to schedule function-based activities.
- Inheritance
-
builtins.objectDurableOrchestrationContext
Constructor
DurableOrchestrationContext(history: List[Dict[Any, Any]], instanceId: str, isReplaying: bool, parentInstanceId: str, input: Any = None, **kwargs)
Parameters
Name | Description |
---|---|
history
Required
|
|
instanceId
Required
|
|
isReplaying
Required
|
|
parentInstanceId
Required
|
|
input
|
Default value: None
|
Methods
call_activity |
Schedule an activity for execution. |
call_activity_with_retry |
Schedule an activity for execution with retry options. |
call_http |
Schedule a durable HTTP call to the specified endpoint. |
call_sub_orchestrator |
Schedule sub-orchestration function named name for execution. |
call_sub_orchestrator_with_retry |
Schedule sub-orchestration function named name for execution, with retry-options. |
continue_as_new |
Schedule the orchestrator to continue as new. |
create_timer |
Create a Durable Timer Task to implement a deadline at which to wake-up the orchestrator. |
from_json |
Convert the value passed into a new instance of the class. |
get_input |
Get the orchestration input. |
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. |
set_custom_status |
Set the customized orchestration status for your orchestrator function. This status is also returned by the orchestration client through the get_status API |
task_all |
Schedule the execution of all activities. Similar to Promise.all. When called with yield or return, returns an array containing the results of all [[Task]]s passed to it. It returns when all of the [[Task]] instances have completed. Throws an exception if any of the activities fails :param activities: List of activities to schedule :type activities: <xref:azure.durable_functions.List[Task]> |
task_any |
Schedule the execution of all activities. Similar to Promise.race. When called with yield or return, returns the first [[Task]] instance to complete. Throws an exception if all of the activities fail |
wait_for_external_event |
Wait asynchronously for an event to be raised with the name name. |
call_activity
Schedule an activity for execution.
call_activity(name: str, input_: Any | None = None) -> Task
Parameters
Name | Description |
---|---|
name
Required
|
The name of the activity function to call. |
input
Required
|
<xref:Optional>[<xref:Any>]
The JSON-serializable input to pass to the activity function. |
input_
|
Default value: None
|
Returns
Type | Description |
---|---|
A Durable Task that completes when the called activity function completes or fails. |
call_activity_with_retry
Schedule an activity for execution with retry options.
call_activity_with_retry(name: str, retry_options: RetryOptions, input_: Any | None = None) -> Task
Parameters
Name | Description |
---|---|
name
Required
|
The name of the activity function to call. |
retry_options
Required
|
The retry options for the activity function. |
input
Required
|
<xref:Optional>[<xref:Any>]
The JSON-serializable input to pass to the activity function. |
input_
|
Default value: None
|
Returns
Type | Description |
---|---|
A Durable Task that completes when the called activity function completes or fails completely. |
call_http
Schedule a durable HTTP call to the specified endpoint.
call_http(method: str, uri: str, content: str | None = None, headers: Dict[str, str] | None = None, token_source: TokenSource = None) -> Task
Parameters
Name | Description |
---|---|
method
Required
|
The HTTP request method. |
uri
Required
|
The HTTP request uri. |
content
|
<xref:Optional>[str]
The HTTP request content. Default value: None
|
headers
|
The HTTP request headers. Default value: None
|
token_source
|
<xref:azure.durable_functions.TokenSource>
The source of OAuth token to add to the request. Default value: None
|
Returns
Type | Description |
---|---|
The durable HTTP request to schedule. |
call_sub_orchestrator
Schedule sub-orchestration function named name for execution.
call_sub_orchestrator(name: str, input_: Any | None = None, instance_id: str | None = None) -> Task
Parameters
Name | Description |
---|---|
name
Required
|
The name of the orchestrator function to call. |
input
Required
|
<xref:Optional>[<xref:Any>]
The JSON-serializable input to pass to the orchestrator function. |
instance_id
|
<xref:Optional>[str]
A unique ID to use for the sub-orchestration instance. Default value: None
|
input_
|
Default value: None
|
Returns
Type | Description |
---|---|
A Durable Task that completes when the called sub-orchestrator completes or fails. |
call_sub_orchestrator_with_retry
Schedule sub-orchestration function named name for execution, with retry-options.
call_sub_orchestrator_with_retry(name: str, retry_options: RetryOptions, input_: Any | None = None, instance_id: str | None = None) -> Task
Parameters
Name | Description |
---|---|
name
Required
|
The name of the activity function to schedule. |
retry_options
Required
|
The settings for retrying this sub-orchestrator in case of a failure. |
input
Required
|
<xref:Optional>[<xref:Any>]
The JSON-serializable input to pass to the activity function. Defaults to None. |
instance_id
|
The instance ID of the sub-orchestrator to call. Default value: None
|
input_
|
Default value: None
|
Returns
Type | Description |
---|---|
A Durable Task that completes when the called sub-orchestrator completes or fails. |
continue_as_new
Schedule the orchestrator to continue as new.
continue_as_new(input_: Any)
Parameters
Name | Description |
---|---|
input
Required
|
The new starting input to the orchestrator. |
input_
Required
|
|
create_timer
Create a Durable Timer Task to implement a deadline at which to wake-up the orchestrator.
create_timer(fire_at: datetime) -> Task
Parameters
Name | Description |
---|---|
fire_at
Required
|
The time for the timer to trigger |
Returns
Type | Description |
---|---|
A Durable Timer Task that schedules the timer to wake up the activity |
from_json
Convert the value passed into a new instance of the class.
from_json(json_string: str)
Parameters
Name | Description |
---|---|
json_string
Required
|
Context passed a JSON serializable value to be converted into an instance of the class |
Returns
Type | Description |
---|---|
New instance of the durable orchestration context class |
get_input
Get the orchestration input.
get_input() -> Any | 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() -> str
Returns
Type | Description |
---|---|
New UUID that is safe for replay within an orchestration or operation. |
set_custom_status
Set the customized orchestration status for your orchestrator function.
This status is also returned by the orchestration client through the get_status API
set_custom_status(status: Any)
Parameters
Name | Description |
---|---|
status
Required
|
Customized status provided by the orchestrator |
task_all
Schedule the execution of all activities.
Similar to Promise.all. When called with yield or return, returns an array containing the results of all [[Task]]s passed to it. It returns when all of the [[Task]] instances have completed.
Throws an exception if any of the activities fails :param activities: List of activities to schedule :type activities: <xref:azure.durable_functions.List[Task]>
task_all(activities: List[Task]) -> TaskSet
Parameters
Name | Description |
---|---|
activities
Required
|
|
Returns
Type | Description |
---|---|
The results of all activities. |
task_any
Schedule the execution of all activities.
Similar to Promise.race. When called with yield or return, returns the first [[Task]] instance to complete.
Throws an exception if all of the activities fail
task_any(activities: List[Task]) -> TaskSet
Parameters
Name | Description |
---|---|
activities
Required
|
<xref:List>[<xref:Task>]
List of activities to schedule |
Returns
Type | Description |
---|---|
The first [[Task]] instance to complete. |
wait_for_external_event
Wait asynchronously for an event to be raised with the name name.
wait_for_external_event(name: str) -> Task
Parameters
Name | Description |
---|---|
name
Required
|
The event name of the event that the task is waiting for. |
Returns
Type | Description |
---|---|
Task to wait for the event |
Attributes
current_utc_datetime
Get the current date/time.
This date/time value is derived from the orchestration history. It always returns the same value at specific points in the orchestrator function code, making it deterministic and safe for replay.
Returns
Type | Description |
---|---|
<xref:azure.durable_functions.datetime>
|
The current date/time in a way that is safe for use by orchestrator functions |
custom_status
Get customized status of current orchestration.
function_context
Get the function level attributes not used by durable orchestrator.
Returns
Type | Description |
---|---|
Object containing function level attributes not used by durable orchestrator. |
histories
Get running history of tasks that have been scheduled.
instance_id
Get the ID of the current orchestration instance.
The instance ID is generated and fixed when the orchestrator function is scheduled. It can be either auto-generated, in which case it is formatted as a GUID, or it can be user-specified with any format.
Returns
Type | Description |
---|---|
The ID of the current orchestration instance. |
is_replaying
Get the value indicating orchestration replaying itself.
This property is useful when there is logic that needs to run only when the orchestrator function is not replaying. For example, certain types of application logging may become too noisy when duplicated as part of orchestrator function replay. The orchestrator code could check to see whether the function is being replayed and then issue the log statements when this value is false.
Returns
Type | Description |
---|---|
Value indicating whether the orchestrator function is currently replaying. |
parent_instance_id
Get the ID of the parent orchestration.
The parent instance ID is generated and fixed when the parent orchestrator function is scheduled. It can be either auto-generated, in which case it is formatted as a GUID, or it can be user-specified with any format.
Returns
Type | Description |
---|---|
ID of the parent orchestration of the current sub-orchestration instance |
will_continue_as_new
Return true if continue_as_new was called.
Azure SDK for Python
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for