0

I want to use Azure Durable Functions to orchestrate my functions. This is my code (auto-generated by VS Code when you create a Durable Function) :

[FunctionName("testorchestration")]
        public static async Task<List<string>> RunOrchestrator(
            [OrchestrationTrigger] DurableOrchestrationContext context)
        {
            var outputs = new List<string>();

            // Replace "hello" with the name of your Durable Activity Function.
            outputs.Add(await context.CallActivityAsync<string>("testorchestration_Hello", "Tokyo"));  
            outputs.Add(await context.CallActivityAsync<string>("testorchestration_Hello", "Seattle")); 
            outputs.Add(await context.CallActivityAsync<string>("testorchestration_Hello", "London")); 

            // returns ["Hello Tokyo!", "Hello Seattle!", "Hello London!"]
            return outputs;
        }

        [FunctionName("testorchestration_Hello")]
        public static string SayHello([ActivityTrigger] string name, ILogger log)
        {
            log.LogInformation($"Saying hello to {name}.");
            return $"Hello {name}!";
        }

        [FunctionName("testorchestration_HttpStart")]
        public static async Task<HttpResponseMessage> HttpStart(
            [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post")]HttpRequestMessage req,
            [OrchestrationClient]DurableOrchestrationClient starter,
            ILogger log)
        {
            // Function input comes from the request content.
            string instanceId = await starter.StartNewAsync("testorchestration", null);

            return await starter.WaitForCompletionOrCreateCheckStatusResponseAsync(req,instanceId);
        }

I add await starter.WaitForCompletionOrCreateCheckStatusResponseAsync(req,instanceId); because I need to wait for completion , and this is my problem. If I wait for completion, it takes about ~2 seconds and sometimes 20 secondes (test on localhost) and I want to understand why because each function takes ~50ms to execute.

Maybe because this method calls await starter.GetStatusAsync(instanceId) everytime until the task is completed ?

ElRoro
  • 203
  • 1
  • 13
  • 1
    Because of the replay behavior I would say. This is by design – Thomas Jul 29 '19 at 10:48
  • 1
    I imagine it polls to check status, that would cause some delays. – juunas Jul 29 '19 at 11:02
  • Yes, it seems that durable function should be used for long running job, if I expect fast response, i should use Azure function call another Azure functions. The replay behavior, the checking status and the fact that there is an Activity History which is called on each call, will cause some delays... – ElRoro Jul 29 '19 at 11:33

0 Answers0