1
votes

So I'm aware in durable functions that when an activity function gets called, the current durable function essentially stops and it waits to start over. My question is how does the original durable function exit? I've done some debugging, and no exception is thrown nor is a value returned. How does it exit?

   [FunctionName("DurableFunction")]
    public static async Task Durable([OrchestrationTrigger] IDurableOrchestrationContext context, ILogger log)
    {
        try
        {
            using (DisposeObject t = new DisposeObject("We created a new context", log))
            {
                string s = context.GetInput<string>();
                string result = await context.CallActivityAsync<string>("ActivityFunction", s);
                log.LogInformation(result);
            }
        }
        catch (Exception e)
        {
            Console.WriteLine(e.ToString());
        }
        finally
        {
            Console.WriteLine("When does this get hit?");
        }
    }

For example, in this example, do disposable object never gets disposed until the end? Is there a way to check when we start a new function?

1
each replay will cause a new instantiation of your object - Alex Gordon
You can check context.IsReplaying. It will be false the first time the function runs - pinkfloydx33

1 Answers

0
votes

Orchestration functions should be some kind of 'stateless'. They should manage and orchestrate the flow of activities (and sub orchestrations) but never perform actions or any IO calls themselves. Having an object that needs disposal indicates either some kind of unmanaged resources or IO bound resources. Which are both a 'no-go' in an orchestration function.

(That might not answer your question technically but hopefully helps you designing them in a good way.)