You can create/find the Shared Access Policies primary/secondary connection at the namespace level or at the entity level.
- 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}
- 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