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"
CodePudding user response:
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"