Problem

Recently I came across an unusual error whilst working with C# Azure Functions. When the Function was executed, the console window showed the following error.

The ‘XXXXXX’ function is in error: Microsoft.Azure.WebJobs.Host: Error indexing method ‘XXXXXX ‘. Microsoft.Azure.WebJobs.Host: Can’t bind parameter ‘data’ to type ‘XXXXXX’.

I checked the Activity function parameter bindings however couldn’t see any obvious issue. However after some head scratching I eventually figured out the source of the issue …

In this post I’ll show you how to resolve this issue.

Azure Functions Logo

Solution

As strange as it sounds … it turns out that you cannot use a parameter named ‘data’ within your Activity Function.

To resolve the issue, simply rename your ‘data’ parameter to something else, the error will disappear and the function will work as expected.

This seems to be a known issue, you can find reports from other users here. Unfortunately it isn’t very well documented and is quite obscure, and for that reason, it can be quite puzzling.

As an example. The below function will fail with the above error. Renaming the ‘data’ parameter to something like ‘greeting’ will resolve the error.

[FunctionName("MyDummyFunction")]
public static async Task> RunOrchestrator(
    [OrchestrationTrigger] IDurableOrchestrationContext context)
{
    var outputs = new List();

    outputs.Add(await context.CallActivityAsync("MyDummyFunction_DoStuff", "Hello World"));
    return outputs;
}

[FunctionName("MyDummyFunction_DoStuff")]
public static string DoStuff([ActivityTrigger] string data, ILogger log)  // Fix: Rename the 'data' param
{
    return $"{data}";
}

Final Thoughts

Well I hope this article has helped solve the issue for you. If you have any other solutions, feel free to share it below. Happy coding! 🙂

Shane Bartholomeusz
Latest posts by Shane Bartholomeusz (see all)