[BUG] Service Bus Extensions: Potential issue with entity path for subscriptions
See original GitHub issueLibrary name and version
Microsoft.Azure.WebJobs.Extensions.ServiceBus 5.1
Describe the bug
I have created a web job function for service bus topic trigger ,as I obtain the connection string from azure (the connection string will contain a entity path).
I have looked into the source code of service bus and found out, during the ServiceBusTriggerAttributeBindingProvider
is creating ServiceBusListener
, it is using EntityNameFormatter.FormatSubscriptionPath(topicName, subscriptionName)
to build a entity path in a format of “{topic-name}/Subscription/{subscription-name}”
so I trace it back to this method CreateBatchMessageReceiver()
is having the issue, when it is creating the client.CreateReceiver(entityPath, options))
,
if you look at the override of that method, it treats the entitypath
as queue name.
Shouldn’t it be using
CreateReceiver(string topicName, string subscriptionName, ServiceBusReceiverOptions options);
Expected behavior
CreateReceiver(string topicName, string subscriptionName, ServiceBusReceiverOptions options);
Actual behavior
CreateReceiver(string queueName, ServiceBusReceiverOptions options);
Reproduction Steps
as described in the description
Environment
windows 10, dotnet 6
Issue Analytics
- State:
- Created 2 years ago
- Comments:9 (5 by maintainers)
Top GitHub Comments
I was able to repro the issue - it looks like it is related to the call that you pointed out @superwalnut. Since we use the receiver overload for creating the message receiver, we end up validating that the subscription name is the same as the topic name from the entityPath section of the connection string, which of course it isn’t. As a workaround, you can remove the entityName from your connection string. Thanks for reporting this!
Thank you Josh for fixing it up. At the mean time we will be using the single message trigger, till you guys address this issue. The connection string is from terraform directly obtained from azure key vault, so for the best not to fiddle with the connection string manually.