0

We want to migrate all currently executing durable functions from a function app to a newly developed function app.

The states of the active durable functions are stored in a table. This means that we just can start the new durable function and it will be able to determine its state. But this means we have to stop a lot of currently executing durable functions.

Our idea was to delete the tables "DurableFunctionsHubHistory" and "DurableFunctionsHubInstances" in the associated storage account. There are no other function apps associated with this storage account which use durable functions.

Is this safe to do or is there a better way to stop a large amount of durable functions?

1 Answers1

0

the question is do you want to stop the functions or in-queue running functions ? if you just want to stop all existing functions, and use the new migrated functions

the quick way would be using disable functions , you can do it in Azure Portal or CLI with below example

az functionapp config appsettings set --name <myFunctionApp> \
--resource-group <myResourceGroup> \
--settings AzureWebJobs.QueueTrigger.Disabled=false

you can also have some helper durable functions to assist you on the state of current large number of functions if you need to stop them.

 var RunningStateFilter = new OrchestrationStatusQueryCondition()
                {
                    RuntimeStatus = new[]
                    {
                        OrchestrationRuntimeStatus.Running
                    },
                    CreatedTimeFrom = DateTime.UtcNow.Subtract(TimeSpan.FromDays(7)),
                    CreatedTimeTo = DateTime.UtcNow.Subtract(TimeSpan.FromDays(1)),
                    PageSize = 100
                };

                OrchestrationStatusQueryResult result = await client.ListInstancesAsync(RunningStateFilter, CancellationToken.None);
                foreach (DurableOrchestrationStatus instance in result.DurableOrchestrationState)
                {
                    NoOfInstance += 1;
                    await client.TerminateAsync(instance.InstanceId, reason);
                }
Turbot
  • 5,095
  • 1
  • 22
  • 30
  • But this would leave the durable functions running. I don't like the idea of having a lot of instances running which will never complete. I feel like this could bite me in a next migration or during general maintance work... – user3181999 Dec 08 '20 at 09:30
  • you can create some helper functions to monitor these along the way, i have put in some example codes to help you on that, you may also look for https://github.com/scale-tone/DurableFunctionsMonitor to see if viable for you if this can help you as well. – Turbot Dec 11 '20 at 06:14
  • Sorry, your last answer reached me too late. I ended up doing what I proposed and deleted the Tables "DurableFunctionsHubHistory" and "DurableFunctionsHubInstances" and created them again empty. This worked as expected and i cound not deteced any problems so far. – user3181999 Dec 13 '20 at 20:43