1

I've created the following using the default provided sample code in Azure Functions:

  1. A Durable Functions HTTP Starter
  2. A Durable Functions Orchestrator
  3. 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:

  1. Runtime version: ~3
  2. Platform: 32 bit
  3. Managed pipeline version: Integrated
Nomadeon
  • 11
  • 3
  • Can you update this to show the exact code in your project? All the functions are called Run and there are no attributes, which makes it a bit hard to work out what the problem might be. – MarkXA May 26 '20 at 17:00
  • There are no method attributes in the default sample code, nor is there a surrounding class definition. The only lines omitted are 'using' and '#r' directives. – Nomadeon May 26 '20 at 21:39
  • Have a look at Chris G's answer here https://stackoverflow.com/a/50411695/1123226 – DhruvJoshi Jun 21 '20 at 20:39

0 Answers0