Here are some related issues : https://github.com/Azure/azure-functions-durable-extension/issues/612
https://github.com/Azure-Samples/durablefunctions-apiscraping-dotnet/issues/1#issuecomment-495236182
Singleton durable function orchestrator being polled through Data Factory running multiple of the same instance
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: