Recently, we were working on Service Bus Triggered Azure Durable Function. After writing the necessary code, we deployed the Durable Function to Azure.
After deploying, while trying to test the function, we faced one weird issue saying “Error: Microsoft.Azure.WebJobs.Host: Error indexing method ‘AzureFunctionName’. Microsoft.Azure.WebJobs.Host: Cannot bind parameter ‘parameterName’ to type MessageReceiver. 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.)”.
Below is the code we were using:
[FunctionName("UpdateGlobalRatesOnRSLs")]
public static async Task Run([ServiceBusTrigger("%QueueName%", Connection = "AzureWebJobsServiceBus")] Message message, MessageReceiver receiver, string lockToken, [OrchestrationClient]DurableOrchestrationClient starter, ILogger log)
{
string inputMessage = Encoding.UTF8.GetString(message.Body);
}
After spending some time on this issue, we figured out that there was nothing wrong except the name of the parameter of type MessageReceiver. As shown above we were using receiver which was throwing error.
It accepts only messageReceiver as the name of the parameter of type MessageReceiver. So, using it as the name of the parameter as shown below fixed the issue.
[FunctionName("UpdateGlobalRatesOnRSLs")]
public static async Task Run([ServiceBusTrigger("%QueueName%", Connection = "AzureWebJobsServiceBus")] Message message, MessageReceiver messageReceiver, string lockToken, [OrchestrationClient]DurableOrchestrationClient starter, ILogger log)
{
string inputMessage = Encoding.UTF8.GetString(message.Body);
}
Hope it helps !!
Just wanted to say thank you – could not figure out what I was doing wrong until I found this post. Much Love!
LikeLike
Thanks Nicholas 😊
LikeLike