D365: Service Bus Triggered Function Error: Cannot bind parameter ‘parameterName’ to type MessageReceiver. Make sure the parameter Type is supported by the binding

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 !!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.