Singleton durable function orchestrator being polled through Data Factory running multiple of the same instance

Christian Hansen 21 Reputation points
2020-11-26T12:02:47.023+00:00

I have a singleton durable function where I do (Omitted some code):

[FunctionName("myStarter")]  
        public static async Task<HttpResponseMessage> HttpStart(  
            [HttpTrigger(AuthorizationLevel.Anonymous, methods: "post", Route = "CalculateLines/{instanceId}")] HttpRequestMessage req,  
            [DurableClient] IDurableOrchestrationClient starter,  
            string instanceId,  
            ILogger log)  
        {  
            var existingInstance = await starter.GetStatusAsync(instanceId);  
            if (existingInstance == null || existingInstance.RuntimeStatus == OrchestrationRuntimeStatus.Completed  
            || existingInstance.RuntimeStatus == OrchestrationRuntimeStatus.Failed  
            || existingInstance.RuntimeStatus == OrchestrationRuntimeStatus.Terminated)  
            {  
                string jsonContent = req.Content.ReadAsStringAsync().Result;  
                await starter.StartNewAsync("RunOrchestrator", instanceId, jsonContent);  
                log.LogInformation($"Started orchestration with ID = '{instanceId}'.");  
                return starter.CreateCheckStatusResponse(req, instanceId);  
            }  
            else  
            {  
                  
                return new HttpResponseMessage(HttpStatusCode.Conflict)  
                {  
                    Content = new StringContent($"An instance with ID '{instanceId}' already exists."),  
                };  
            }  
        }  

[FunctionName("RunOrchestrator")]  
    public static async Task RunOrchestrator(  
        [OrchestrationTrigger] IDurableOrchestrationContext context)  
    {  
        if (!context.IsReplaying)  
        {  
            string body = context.GetInput<string>();  
            await context.CallActivityAsync("ActivityRunner", body);  
        }  
    }  

[FunctionName("ActivityRunner")]  
public static void ActivityRunner([ActivityTrigger] string body, ILogger log)  
{  
     log.LogInformation("Starting new activity");  
     // do more  
}  

Then in Data Factory I have set up a pipeline that runs the function, and the a web activity that looks at the statusQueryGetUri the Orchestrator returns, it does this multiple times once a minute or so.

How come when I go into the monitor of my app I keep seeing logs printing "Starting new activity" when I only did the post request once?

EDIT: Forgot to mention that it seems like it starts the same execution again, and not that it runs old instances

To test I called with a hardcoded instanceId (1) just once, but if I go into the monitor and look at orchestrations I see this in the details:

43062-image.png

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,978 questions
{count} votes

1 answer

Sort by: Most helpful
  1. JayaC-MSFT 5,531 Reputation points
    2020-12-03T21:12:37.727+00:00
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.