I just started to work with Azure functions, specifically durable functions.
I'm working off of https://docs.microsoft.com/en-us/azure/azure-functions/durable/durable-functions-create-first-csharp
I added a new azure durable function and the default code showed up below.
I saw that my libraries are durable function version 2 so I had to make a couple of changes to class names for it to resolve (link is in the above link that discusses the changes):
[FunctionName("TestFunction")]
public static async Task<List<string>> RunOrchestrator(
[OrchestrationTrigger] IDurableOrchestrationContext context)
{
var outputs = new List<string>();
// Replace "hello" with the name of your Durable Activity Function.
outputs.Add(await context.CallActivityAsync<string>("TestFunction_Hello", "Tokyo"));
outputs.Add(await context.CallActivityAsync<string>("TestFunction_Hello", "Seattle"));
outputs.Add(await context.CallActivityAsync<string>("TestFunction_Hello", "London"));
// returns ["Hello Tokyo!", "Hello Seattle!", "Hello London!"]
return outputs;
}
[FunctionName("TestFunction_Hello")]
public static string SayHello([ActivityTrigger] string name, ILogger log)
{
log.LogInformation($"Saying hello to {name}.");
return $"Hello {name}!";
}
[FunctionName("TestFunction_HttpStart")]
public static async Task<HttpResponseMessage> HttpStart(
[HttpTrigger(AuthorizationLevel.Anonymous, "get", "post")]HttpRequestMessage req,
[OrchestrationClient]IDurableOrchestrationClient starter, ILogger log)
{
// Function input comes from the request content.
string instanceId = await starter.StartNewAsync("TestFunction", null);
log.LogInformation($"Started orchestration with ID = '{instanceId}'.");
return starter.CreateCheckStatusResponse(req, instanceId);
}
When I run this locally it starts the storage emulator but then I get a couple of errors:
Microsoft.Azure.WebJobs.Host: Error indexing method 'TestFunction_HttpStart'. Microsoft.Azure.WebJobs.Host: Cannot bind parameter 'starter' to type IDurableOrchestrationClient. Make sure the parameter Type is supported by the binding. If you're using binding extensions (e.g. Azure Storage, ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (e.g. builder.AddAzureStorage(), builder.AddServiceBus(), builder.AddTimers(), etc.).
and
Microsoft.Azure.WebJobs.Host: Error indexing method 'TestFunction_HttpStart'. Microsoft.Azure.WebJobs.Host: Cannot bind parameter 'starter' to type IDurableOrchestrationClient. Make sure the parameter Type is supported by the binding. If you're using binding extensions (e.g. Azure Storage, ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (e.g. builder.AddAzureStorage(), builder.AddServiceBus(), builder.AddTimers(), etc.).
Why are these errors showing up from the default test code and how do I fix it?