I've created the following using the default provided sample code in Azure Functions:
- A Durable Functions HTTP Starter
- A Durable Functions Orchestrator
- A Durable Functions Activity named Hello1
The HTTP Starter calls the Orchestrator, but the Orchestrator fails to call the Activity.
Orchestrator code, which is identical to the original sample except with fewer output additions and the Activity Name set to Hello1:
public static async Task<List<string>> Run(DurableOrchestrationContext context)
{
var outputs = new List<string>();
// Replace "Hello" with the name of your Durable Activity Function.
outputs.Add(await context.CallActivityAsync<string>("Hello1", "Tokyo"));
// returns ["Hello Tokyo!", "Hello Seattle!", "Hello London!"]
return outputs;
}
Orchestrator produces the following error:
Function 'DurableFunctionsOrchestrator1 (Orchestrator)' failed with an error. Reason: System.AggregateException: One or more errors occurred. (Multithreaded execution was detected. This can happen if the orchestrator function code awaits on a task that was not created by a DurableOrchestrationContext method.
The only await
call is done on the DurableOrchestrationContext
object, so what gives?
My HTTP Starter is the default sample code unchanged:
public static async Task<HttpResponseMessage> Run(
HttpRequestMessage req,
DurableOrchestrationClient starter,
string functionName,
ILogger log)
{
// Function input comes from the request content.
dynamic eventData = await req.Content.ReadAsAsync<object>();
// Pass the function name as part of the route
string instanceId = await starter.StartNewAsync(functionName, eventData);
log.LogInformation($"Started orchestration with ID = '{instanceId}'.");
return starter.CreateCheckStatusResponse(req, instanceId);
}
Activity code is likewise stock sample code:
public static string Run(string name)
{
return $"Hello {name}!";
}
Function App Service settings:
- Runtime version: ~3
- Platform: 32 bit
- Managed pipeline version: Integrated