Is it possibly to somehow get notified that the durable function as been or about to be terminated, such that it is possibly to initiate cleanup of the already finished activity functions for example? In my example we're sending multiple requests to a subsystem and need to revoke or refund the orders in case of the durable function is being terminated.
Asked
Active
Viewed 451 times
1 Answers
0
I don't believe that there is any way to subscribe to Terminatation events in Durable Functions, as the Durable Task Framework handles this before user code is ever invoked.
One option instead of using the explicit terminate API built into Durable Functions is to instead listen to some CustomTerminate
event within your orchestration, using a Task.WhenAny()
approach whenever you schedule an activity or suborchestration. Then, if you ever receive this CustomTerminate
event instead of the Activity or SubOrchestration response, you could manually handle the cleanup at this point.

Connor McMahon
- 1,318
- 7
- 15
-
I ended up layering my activity functions in SubOrchestrations. With this approach, even if the main orchestration was terminated, the result of the SubOrchestrations are still available to read. I created a scheduled orchestration to handle the incomplete orders by reading the results of the suborchestrations. The termination is not always possible to control, in case the function is terminated or stopped from the azure portal or due to deployment of a new version of the function. Thanks for your anwser. – Dan Persson Jan 15 '21 at 06:05