【问题标题】:What is the correct format of connectionstring for Azure Service Bus when using Managed Identity for my App Service?为我的应用服务使用托管标识时,Azure 服务总线的连接字符串的正确格式是什么?
【发布时间】:2021-12-19 08:39:27
【问题描述】:

我在 Azure 中将此应用服务作为 Web 作业运行。该应用程序是使用 NServiceBus 构建的以前的 Windows 服务,我一直在重新配置它以在 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"

【问题讨论】:

  • 应该可以使用 MSI 从应用服务到 Azure 服务总线,例如 github.com/Azure-Samples/app-service-msi-servicebus-dotnet。但似乎我无法使用 NServiceBus 以这种方式配置它,或者我遗漏了一些东西

标签: azure azureservicebus nservicebus azure-appservice


【解决方案1】:

刚刚遇到了与 NServiceBus 相同的问题。而不是:

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

刚刚设置:

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

【讨论】:

  • 好的,谢谢。我也尝试过,但收到另一个异常并忽略了这是我在 Visual Studio 本地运行的正确异常。
  • 有关答案的更多信息,您可以参考 NServiceBus 论坛上的 thread
猜你喜欢
  • 2021-01-24
  • 2022-12-19
  • 2021-11-08
  • 1970-01-01
  • 2022-10-20
  • 1970-01-01
  • 2021-08-08
  • 1970-01-01
  • 2018-07-22
相关资源
最近更新 更多