I wrote an Azure Function App with Durable Functions. While testing with a large dataset, I realized that the functionTimeout value was 10 mins. This caused some of the orchestrations to timeout. Thus began an indefinite number of retries of the failed orchestrations. I have increased the timeout setting to 1 hour 30 mins, but some of the old retries are still pending and therefore still running. I have tried stopping the function app and restarting it back up, but the execution of the orchestrations continued.
Two questions:
- Is there a manual way to stop the execution of the orchestrations other than stopping the function app?
- How do I set the number of retries to 0?
Here's the code for initiating the orchestrations:
import azure.functions as func
import azure.durable_functions as df
import logging
app = df.DFApp(http_auth_level=func.AuthLevel.FUNCTION)
#HTTP triggered function invoked by the client
@app.route(route="orchestrators/{functionName}/{stateabbr}/{county}")
@app.durable_client_input(client_name="starter")
async def CleanMatchEnrichParcel(req: func.HttpRequest, starter: str) -> func.HttpResponse:
logging.info("CleanMatchEnrichParcel HTTP trigger function processed a request.")
fname = req.route_params["functionName"]
stateabbr = req.route_params["stateabbr"]
county = req.route_params["county"]
fparams = {"stateabbr": stateabbr, "county": county}
instance_id = await starter.start_new(fname, None, fparams)
logging.info(f"Started orchestration with ID = '{instance_id}'.")
response = starter.create_check_status_response(req, instance_id)
return(response)
@app.orchestration_trigger(context_name="context")
def orchestrator_function(context: df.DurableOrchestrationContext):
#orchestration function code
return(response)
I wrote an Azure Function App with Durable Functions. While testing with a large dataset, I realized that the functionTimeout value was 10 mins. This caused some of the orchestrations to timeout. Thus began an indefinite number of retries of the failed orchestrations. I have increased the timeout setting to 1 hour 30 mins, but some of the old retries are still pending and therefore still running. I have tried stopping the function app and restarting it back up, but the execution of the orchestrations continued.
Two questions:
- Is there a manual way to stop the execution of the orchestrations other than stopping the function app?
- How do I set the number of retries to 0?
Here's the code for initiating the orchestrations:
import azure.functions as func
import azure.durable_functions as df
import logging
app = df.DFApp(http_auth_level=func.AuthLevel.FUNCTION)
#HTTP triggered function invoked by the client
@app.route(route="orchestrators/{functionName}/{stateabbr}/{county}")
@app.durable_client_input(client_name="starter")
async def CleanMatchEnrichParcel(req: func.HttpRequest, starter: str) -> func.HttpResponse:
logging.info("CleanMatchEnrichParcel HTTP trigger function processed a request.")
fname = req.route_params["functionName"]
stateabbr = req.route_params["stateabbr"]
county = req.route_params["county"]
fparams = {"stateabbr": stateabbr, "county": county}
instance_id = await starter.start_new(fname, None, fparams)
logging.info(f"Started orchestration with ID = '{instance_id}'.")
response = starter.create_check_status_response(req, instance_id)
return(response)
@app.orchestration_trigger(context_name="context")
def orchestrator_function(context: df.DurableOrchestrationContext):
#orchestration function code
return(response)
Share
Improve this question
edited 2 days ago
anilcreates
asked Feb 18 at 4:01
anilcreatesanilcreates
93 bronze badges
4
|
1 Answer
Reset to default 0
- Is there a manual way to stop the execution of the orchestrations other than stopping the function app?
You can stop the running Orchestration by suspending the Orchestration, refer MSDOC
suspend_reason = "Found a bug"
client.suspend(instance_id, suspend_reason)
Code:
myApp = df.DFApp(http_auth_level=func.AuthLevel.ANONYMOUS)
@myApp.route(route="orchestrators/{functionName}")
@myApp.durable_client_input(client_name="client")
async def http_start(req: func.HttpRequest, client):
function_name = req.route_params.get('functionName')
instance_id = await client.start_new(function_name)
response = client.create_check_status_response(req, instance_id)
await client.suspend(instance_id, "found a bug")
logging.info("Orchestration suspended")
return response
Console response:
Functions:
http_start: http://localhost:7071/api/orchestrators/{functionName}
hello: activityTrigger
hello_orchestrator: orchestrationTrigger
For detailed output, run func with --verbose flag.
[2025-02-18T07:55:19.194Z] Host lock lease acquired by instance ID '000000000000000000000000F72731CC'.
[2025-02-18T07:55:50.392Z] Executing 'Functions.http_start' (Reason='This function was programmatically called via the host APIs.', Id=05a6a228-0dfb-4dcd-8c91-29da78ed0a1e)
[2025-02-18T07:55:50.760Z] Orchestration suspended
[2025-02-18T07:55:50.960Z] Executing 'Functions.hello_orchestrator' (Reason='(null)', Id=07f199d9-fd10-422b-a66e-e84677011a30)
[2025-02-18T07:55:50.966Z] Executed 'Functions.http_start' (Succeeded, Id=05a6a228-0dfb-4dcd-8c91-29da78ed0a1e, Duration=607ms)
[2025-02-18T07:55:51.054Z] Executed 'Functions.hello_orchestrator' (Succeeded, Id=07f199d9-fd10-422b-a66e-e84677011a30, Duration=110ms)
[2025-02-18T07:55:51.126Z] Executing 'Functions.hello' (Reason='(null)', Id=31e72fb9-ce64-4983-a931-8ceb9b1be8c1)
[2025-02-18T07:55:51.133Z] Executed 'Functions.hello' (Succeeded, Id=31e72fb9-ce64-4983-a931-8ceb9b1be8c1, Duration=9ms)
[2025-02-18T07:55:51.154Z] Executing 'Functions.hello_orchestrator' (Reason='(null)', Id=690cd49d-2765-41e0-bb43-e8b85c51f18a)
[2025-02-18T07:55:51.167Z] Executed 'Functions.hello_orchestrator' (Succeeded, Id=690cd49d-2765-41e0-bb43-e8b85c51f18a, Duration=15ms)
[2025-02-18T07:55:51.201Z] Executing 'Functions.hello_orchestrator' (Reason='(null)', Id=2d51e367-b295-45b4-ace4-a24dd1c5615e)
[2025-02-18T07:55:51.210Z] Executed 'Functions.hello_orchestrator' (Succeeded, Id=2d51e367-b295-45b4-ace4-a24dd1c5615e, Duration=9ms)
Orchestration Status can be seen as below:
You can also terminate the Orchestration by running the terminatePostURI
of the function:
[2025-02-18T08:03:25.173Z] 523f442ed0574d3dab2f2d0226a27ce7: Function 'hello_orchestrator (Orchestrator)' was terminated.
Reason: found a bug. State: Terminated. RuntimeStatus: Terminated. HubName: TestHubName. AppName: . SlotName: . ExtensionVersion: 2.13.2. SequenceNumber: 12.
[2025-02-18T08:03:25.233Z] Executing 'Functions.hello_orchestrator' (Reason='(null)', Id=95c9b9a7-5728-4ad5-ab35-439a6d377714)
[2025-02-18T08:03:25.242Z] Executed 'Functions.hello_orchestrator' (Succeeded, Id=95c9b9a7-5728-4ad5-ab35-439a6d377714, Duration=10ms)
- How do I set the number of retries to 0?
Set max_number_of_attempts=1
, refer MSDOC.
first_retry_interval_in_milliseconds = 5000
max_number_of_attempts = 1
retry_options = df.RetryOptions(first_retry_interval_in_milliseconds, max_number_of_attempts)
Code:
# Orchestrator
@myApp.orchestration_trigger(context_name="context")
def hello_orchestrator(context: df.DurableOrchestrationContext):
first_retry_interval_in_milliseconds = 5000
max_number_of_attempts = 1
retry_options = df.RetryOptions(first_retry_interval_in_milliseconds, max_number_of_attempts)
result = yield context.call_activity_with_retry('hello', retry_options)
result1 = yield context.call_activity("hello", "Seattle")
result2 = yield context.call_activity("hello", "Tokyo")
result3 = yield context.call_activity("hello", "London")
return [ result1, result2, result3]
func durable terminate --id <orchestration_id> --reason <reason>
. Refer Msdoc – Pravallika KV Commented 2 days ago