为我的应用服务使用托管标识时,Azure 服务总线的连接字符串的正确格式是什么?

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

我在 Azure 运行 中将此应用服务作为 Web 作业。该应用程序以前是 Windows 使用 NServiceBus 构建的服务,我一直在重新配置它以在 Azure 中工作。

该应用程序正在使用 AzureServiceBusTransport,我的 Azure 服务总线设置了队列。

我成功了...当我使用像这样在我的连接字符串中配置的共享访问密钥时;

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

为了使其与托管身份一起使用,我在我的 NServiceBus EndpointConfiguration 中重新配置了;

transport.CustomTokenCredential(new DefaultAzureCredential());

我还将连接字符串更改为以下内容;

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

但是当我尝试改用托管身份时,出现以下异常;

ArgumentException: 值 'Endpoint=sb://MYNAMESPACE.servicebus.windows.net/;Authentication=ManagedIdentity' 不是格式正确的服务总线完全限定命名空间。

当我使用共享访问密钥时,MYNAMESPACE 显然是正确的,但当我使用托管身份时却不是?

我们确实有一个可以使用托管身份的 Azure 功能,在这种情况下使用;

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

只是 运行 遇到与 NServiceBus 相同的问题。而不是:

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

刚刚设置:

"ConnectionString": "MYNAMESPACE.servicebus.windows.net"