Service Bus Connection in Azure Portal Does Not Work

David McCarter 1 Reputation point MVP
2020-06-22T20:00:34.807+00:00

When I copy the connection string from the Azure Portal for a Service Bus Queue does not work. I keep getting that EntityPath should not be in the connection string. This has been happening for years! Please fix.

10394-screen-grab.jpg

Azure Service Bus
Azure Service Bus
An Azure service that provides cloud messaging as a service and hybrid integration.
571 questions
{count} votes

1 answer

Sort by: Most helpful
  1. MayankBargali-MSFT 69,846 Reputation points
    2020-07-02T11:46:28.193+00:00

    Hi @David McCarter

    You can create/find the Shared Access Policies primary/secondary connection at the namespace level or at the entity level.

    1. If you are using the namespace level connection string then it follows the format Endpoint=sb://{namespacename}.servicebus.windows.net/;SharedAccessKeyName={SharedAccessKeyName};SharedAccessKey={Primary/Secondary Key}
    2. If you are using the entity level connection string then it appends the EntityPath in the connection string
      Endpoint=sb://{namespacename}.servicebus.windows.net/;SharedAccessKeyName={SharedAccessKeyName};SharedAccessKey={Primary/Secondary Key};EntityPath={EntityName}

    We have different overloaded methods when you create the QueueClient/TopicClient in any of the languages
    https://learn.microsoft.com/en-us/dotnet/api/microsoft.servicebus.messaging.queueclient.createfromconnectionstring?view=azure-dotnet
    https://learn.microsoft.com/en-us/dotnet/api/microsoft.servicebus.messaging.topicclient.createfromconnectionstring?view=azure-dotnet

    If you look into the above document you will able to see
    CreateFromConnectionString(String) method that expects the connection string supplied has entity level information
    CreateFromConnectionString(String, String) method when the connection string does not use the EntityPath property.

    CreateFromConnectionString(String, String) method that expects the connection string supplied has entity level information. So if I look into the error message I can see you are using ServiceBusConnection Class and the overloaded method that your application is using doesn't take entity path in the connection string: https://learn.microsoft.com/en-us/dotnet/api/microsoft.azure.servicebus.servicebusconnection?view=azure-dotnet

    Hope the above helps you to understand different ways of using the namespace and entity level connection string.
    Let me know if you have any queries

    0 comments No comments