I have application that uses Azure Durable Orchestrators and Activties and I am trying to write Integration Test for it by following the instructions here.. Mind you this Function App runs successfully in the Azure Runtime, so I am trying to isolate why it is throwing this misleading error using this approach
I am using a custom configuration that utilizes the HodtBuilder setup below
public FunctioningInitializer(int portNumber)
{
configuration = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.functioning.json")
.Build();
var host = new HostBuilder()
.ConfigureWebJobs((context, builder) =>
{
new FunctioningStartup(portNumber).Configure(new WebJobsBuilderContext()
{
ApplicationRootPath = context.HostingEnvironment.ContentRootPath,
Configuration = configuration,
EnvironmentName = context.HostingEnvironment.EnvironmentName
}, builder);
// Add Durable Task services
builder.AddDurableTask(options =>
{
options.HubName = "AppHub";
});
builder.AddAzureStorageCoreServices();
})
.ConfigureAppConfiguration((context, builder) =>
{
// Existing configuration settings
})
.Build();
try
{
host.Run();
//host.StartAsync().GetAwaiter().GetResult();
}
catch (FunctionIndexingException ex)
{
Console.WriteLine(ex.Message);
}
ServiceProvider = host.Services;
}
public IServiceProvider ServiceProvider { get; }
But when I run this I get the below exception
OneTimeSetUp: Microsoft.Azure.WebJobs.Host.Indexers.FunctionIndexingException : Error indexing method 'FunctioningTrigger' ----> System.InvalidOperationException : 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.
The function is referencing in this exception is defined as below
public async Task<IActionResult> FunctioningTrigger(
[HttpTrigger(AuthorizationLevel.Anonymous, "put", "patch", Route = "v3/functioning")] HttpRequest request,
[DurableClient] IDurableOrchestrationClient durableClient,
ILogger logger)
So I am wondering why I am getting this wrong signature exception, any help or hint would be appreciated.
Update
Seems the WebJobs SDK does not know how to use the [DurableClient] IDurableOrchestrationClient durableClient binding during Function Indexing, removing that binding makes the Test Host start successfully.