Using a managed identity with AzureServiceBusTransport no longer works post Transport.AzureServiceBus upgrade to 3.1.0

After upgrading AzureServiceBusTransport (from 2.03 to 3.0.1), and re-configuring using a managed identify, it generates an exception: ‘The value ‘’ is not a well-formed Service Bus fully qualified namespace. (Parameter ‘fullyQualifiedNamespace’)’

Stepping through AzureServiceBusTransport.cs the new configuration uses the FullyQualifiedNamespace. When it sets the administrativeClient (line 95) ConnectionString is null, going on to generate the exception. Am I missing a configuration?

Configuration (3.1.0):

var credential = new DefaultAzureCredential(new DefaultAzureCredentialOptions { ManagedIdentityClientId = identityClientId });
var transport = new AzureServiceBusTransport("[NAMESPACE].servicebus.windows.net", credential);

Configuration (2.03):

            var transport = endpointConfiguration.UseTransport<AzureServiceBusTransport>();
            transport.ConnectionString("[NAMESPACE].servicebus.windows.net");
            transport.CustomTokenCredential(credential);

Exception:

System.ArgumentException
  HResult=0x80070057
  Message=The value '' is not a well-formed Service Bus fully qualified namespace. (Parameter 'fullyQualifiedNamespace')
  Source=Azure.Messaging.ServiceBus
  StackTrace:
   at Azure.Core.Argument.AssertWellFormedServiceBusNamespace(String argumentValue, String argumentName) in /_/sdk/servicebus/Azure.Messaging.ServiceBus/src/Core/Argument.cs:line 156
   at Azure.Messaging.ServiceBus.Administration.ServiceBusAdministrationClient..ctor(String fullyQualifiedNamespace, ServiceBusTokenCredential credential, ServiceBusAdministrationClientOptions options) in /_/sdk/servicebus/Azure.Messaging.ServiceBus/src/Administration/ServiceBusAdministrationClient.cs:line 179
   at Azure.Messaging.ServiceBus.Administration.ServiceBusAdministrationClient..ctor(String fullyQualifiedNamespace, TokenCredential credential) in /_/sdk/servicebus/Azure.Messaging.ServiceBus/src/Administration/ServiceBusAdministrationClient.cs:line 149
   at NServiceBus.AzureServiceBusTransport.<Initialize>d__3.MoveNext() in /_/src/Transport/AzureServiceBusTransport.cs:line 95
   at NServiceBus.TransportSeam.<CreateTransportInfrastructure>d__6.MoveNext() in /_/src/NServiceBus.Core/Transports/TransportSeam.cs:line 36
   at NServiceBus.StartableEndpoint.<Start>d__1.MoveNext() in /_/src/NServiceBus.Core/StartableEndpoint.cs:line 35
   at NServiceBus.HostingComponent.<Start>d__7.MoveNext() in /_/src/NServiceBus.Core/Hosting/HostingComponent.cs:line 87
   at NServiceBus.ExternallyManagedContainerHost.<Start>d__9.MoveNext() in /_/src/NServiceBus.Core/Hosting/ExternallyManagedContainerHost.cs:line 47
   at NServiceBus.Extensions.Hosting.NServiceBusHostedService.<StartAsync>d__1.MoveNext() in /_/src/NServiceBus.Extensions.Hosting/NServiceBusHostedService.cs:line 30
   at Microsoft.Extensions.Hosting.Internal.Host.<StartAsync>d__12.MoveNext() in /_/src/libraries/Microsoft.Extensions.Hosting/src/Internal/Host.cs:line 73
   at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.<RunAsync>d__4.MoveNext() in /_/src/libraries/Microsoft.Extensions.Hosting.Abstractions/src/HostingAbstractionsHostExtensions.cs:line 66
   at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.<RunAsync>d__4.MoveNext() in /_/src/libraries/Microsoft.Extensions.Hosting.Abstractions/src/HostingAbstractionsHostExtensions.cs:line 76
   at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.Run(IHost host) in /_/src/libraries/Microsoft.Extensions.Hosting.Abstractions/src/HostingAbstractionsHostExtensions.cs:line 51
   at Program.<Main>$(String[] args) in C:\Users\NickSimpson\source\repos\TSF\Insight\Service\src\Directory\Directory.Infrastructure.Command.Api\Program.cs:line 156

Hi @Nick_Simpson

We have changed the dual purpose of the connection string. TokenCredentials are now an explicit option with dedicated arguments to the transport constructor.

Regards,
Daniel

Thanks Daniel. If you can see in the updated code Configuration (3.1.0), the instructions in the referenced article are being followed. The namespace and the token credential are provided in the constructor.

When stepping through AzureServiceBusTransport.cs there is a reference to ConnectionString (line 95) which is not being used/set in the constructor, and is the origination of the error.

Thanks. Nick

Hi @Nick_Simpson

sigh that’s a face palm mistake of myself :smiley: Sorry for that.

I have raised an issue Attempting to use managed identity throws an ArgumentException · Issue #700 · Particular/NServiceBus.Transport.AzureServiceBus · GitHub

I’ll keep you posted about the resolution

Daniel

1 Like

Nick,

We have started fixing the bug. Might take a bit until it is out, though. I’ll keep you posted.

Daniel

Hi Daniel. Many thanks for the update. It’s impacting poc work so not critical but appreciate a resolution as no viable workaround beyond using a connecting string with keys. Thanks. Nick

@Nick_Simpson

Things are released

Sorry again for this, and thanks for the patience. This is definitely a testing gap we have in the transport that we will have to close at some point.

Daniel

Thanks Daniel. Just upgraded to 3.1.1, tested, and it works successfully. Really appreciate the quick turnaround. Nick

1 Like