Why is my RootManageSharedAccessKey Connection String Invalid?
Code:
When executing the code below, I receive an error about an invalid connection string:
serviceBusClient <- new ServiceBusClient(connectionString)
Error:
System.NotImplementedException: 'The method or operation is not implemented.'
System.ArgumentException: 'The connection string used for an Service Bus client must specify the Service Bus namespace host and either a Shared Access Key (both the name and value) OR a Shared Access Signature to be valid. Parameter name: connectionString'
ConnectionString:
"Endpoint=sb://myNameSpace.servicebus.windows.net/;TransportType=AmqpWebSockets;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=*******************************************="
I also tried removing the TransportType property from the connection string:
"Endpoint=sb://myNameSpace.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=*******************************************="
The connection string was derived from the Shared Access Policy of my Service Bus resource:
Context:
Xamarin.Forms (Android)
Azure.Messaging.ServiceBus
NuGet Packages:
Azure.Messaging.ServiceBus (7.11.1) Xamarin.Forms (5.0.0.2545)
For those who may be interested, the root cause of this turned out to be that the connection string passed to ServiceBusClient
was JSON-encoded, causing two quote literals to be embedded. As a result, there was no Endpoint=
token present (it was "Endpoint=
) which left the client unable to determine where to connect to.