Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the correct format of connectionstring for Azure Service Bus when using Managed Identity for my App Service?

I have this App Service in Azure running as a Web Job. The application is a former Windows Service built using NServiceBus and I have been reconfiguring it to work in Azure.

The application is using AzureServiceBusTransport and I have my Azure Service Bus with a queue set up.

I got it working... when I am using a Shared Access Key configured in my connectionstring like this;

"ConnectionString": "Endpoint=sb://MYNAMESPACE.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=***"

To make it work with Managed Identity I have reconfigured in my NServiceBus EndpointConfiguration with;

transport.CustomTokenCredential(new DefaultAzureCredential());

I also changed my connectionstring to the following;

"ConnectionString": "Endpoint=sb://MYNAMESPACE.servicebus.windows.net/;Authentication=ManagedIdentity"

But when I try to use Managed Identity instead I get the following exception;

ArgumentException: The value 'Endpoint=sb://MYNAMESPACE.servicebus.windows.net/;Authentication=ManagedIdentity' is not a well-formed Service Bus fully qualified namespace.

MYNAMESPACE is obviously correct when I use Shared Access Key but not when I use Managed Identity?

We do have an Azure Function that CAN use Managed Identity and is in that case using;

"ConnectionString": "Endpoint=sb://MYNAMESPACE.servicebus.windows.net/;Authentication=ManagedIdentity"
like image 372
Per Avatar asked Oct 17 '25 03:10

Per


1 Answers

Just ran into the same issue with NServiceBus. Instead of:

"ConnectionString": "Endpoint=sb://MYNAMESPACE.servicebus.windows.net/;Authentication=ManagedIdentity"

just set:

"ConnectionString": "MYNAMESPACE.servicebus.windows.net"
like image 61
Thibault Avatar answered Oct 18 '25 20:10

Thibault



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!