This is how I use async/Task in Console App:
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace CaseDurableFunctionConsole
{
class Program
{
static async Task<List<string>> RunOrchestrator()
{
Console.WriteLine("Hello World!");
Console.ReadLine();
var outputs = new List<string>();
return outputs;
}
static void Main(string[] args)
{
RunOrchestrator();
}
}
}
This works well and this is the output:
(Even without using await, it shows the right result.)
But when I use async/Task in Azure Functions, like this:
[FunctionName("Function1")]
public static async Task<List<string>> RunOrchestrator(
[OrchestrationClient] DurableOrchestrationClient orchestrationClient)
{
var outputs = new List<string>();
await Task.Delay(1);
return outputs;
}
Then it comes up with an error after started.
[2019/11/25 5:50:50] Error indexing method 'Function1' [2019/11/25 5:50:50] Microsoft.Azure.WebJobs.Host: Error indexing method 'Function1'. Microsoft.Azure.WebJobs.Host: Functions must return Task or void, have a binding attribute for the return value, or be triggered by a binding that natively supports return values.
[2019/11/25 5:50:56] The 'Function1' function is in error: Microsoft.Azure.WebJobs.Host: Error indexing method 'Function1'. Microsoft.Azure.WebJobs.Host: Functions must return Task or void, have a binding attribute for the return value, or be triggered by a binding that natively supports return values.
How can I fix this by modify my Function Code?