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
- history
- instanceId
- isReplaying
- parentInstanceId
- input
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
- input
- <xref:Optional>[<xref:Any>]
The JSON-serializable input to pass to the activity function.
- input_
Returns
A Durable Task that completes when the called activity function completes or fails.
Return type
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
- input
- <xref:Optional>[<xref:Any>]
The JSON-serializable input to pass to the activity function.
- input_
Returns
A Durable Task that completes when the called activity function completes or fails completely.
Return type
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
- token_source
- <xref:azure.durable_functions.TokenSource>
The source of OAuth token to add to the request.
Returns
The durable HTTP request to schedule.
Return type
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
- input
- <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.
- input_
Returns
A Durable Task that completes when the called sub-orchestrator completes or fails.
Return type
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
- retry_options
- RetryOptions
The settings for retrying this sub-orchestrator in case of a failure.
- input
- <xref:Optional>[<xref:Any>]
The JSON-serializable input to pass to the activity function. Defaults to None.
- input_
Returns
A Durable Task that completes when the called sub-orchestrator completes or fails.
Return type
continue_as_new
Schedule the orchestrator to continue as new.
continue_as_new(input_: Any)
Parameters
- input_
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
Returns
A Durable Timer Task that schedules the timer to wake up the activity
Return type
from_json
Convert the value passed into a new instance of the class.
from_json(json_string: str)
Parameters
- json_string
- str
Context passed a JSON serializable value to be converted into an instance of the class
Returns
New instance of the durable orchestration context class
Return type
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
New UUID that is safe for replay within an orchestration or operation.
Return type
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
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
- activities
Returns
The results of all activities.
Return type
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
- activities
- <xref:List>[<xref:Task>]
List of activities to schedule
Returns
The first [[Task]] instance to complete.
Return type
wait_for_external_event
Wait asynchronously for an event to be raised with the name name.
wait_for_external_event(name: str) -> Task
Parameters
Returns
Task to wait for the event
Return type
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
The current date/time in a way that is safe for use by orchestrator functions
Return type
custom_status
Get customized status of current orchestration.
function_context
Get the function level attributes not used by durable orchestrator.
Returns
Object containing function level attributes not used by durable orchestrator.
Return type
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
The ID of the current orchestration instance.
Return type
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
Value indicating whether the orchestrator function is currently replaying.
Return type
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
ID of the parent orchestration of the current sub-orchestration instance
Return type
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