0
votes

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

1 Answers

0
votes

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);
                }