When I try to run a newly created Azure function locally and getting a message from a ServiceBus topic I get this error:
DeliveryCount = ‘mySbMsg.DeliveryCount’ threw an exception of type ‘System.InvalidOperationException’
This is the code I ran:
VS snippet
"ex" is not the values I am using, just changed for the snippet.
2
Answers
@Pravallika KV, Thank you so much for taking the time to reply. :)
I tried your steps, but still got the same error. When I received the message as string it worked, but not with the
ServiceBusRecievedMessage
class.After I updated this NuGet it works with
ServiceBusRecievedMessage
class:Microsoft.Azure.WebJobs.Extensions.ServiceBus
.As per my research, I found that this exception occurs when the Delivery Count property is not set properly.
Check if the below troubleshooting steps help to fix the issue:
Basically, InvalidOperationException occurs when the requested user operation isn’t allowed within the service. Check for the error details.
I have created a ServiceBusTopicTrigger function to check and it worked as expected:
Code Snippet:
Output:
References: