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

标签 azure azureservicebus nservicebus azure-appservice

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

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

我得到了它的工作......当我使用在我的连接字符串中配置的共享访问 key 时,如下所示;

"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”不是格式良好的服务总线完全限定命名空间。

当我使用共享访问 key 时,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"

关于azure - 在我的应用服务中使用托管标识时,Azure 服务总线的连接字符串的正确格式是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69850737/

相关文章:

c# - JsonConvert 和 NServiceBus 命名空间冲突

json - Azure ADF - 只能使用整数索引选择数组元素

database - Azure Sqldatabase 还是虚拟专用服务器?

debugging - 本地 Azure 待办事项列表

azure - 如何从多个azure应用程序服务收集结果并推送到主题

Azure WebJobs ServiceBus 返回异常 : found 2 DNS claims in authorization context

nservicebus - 在 NServiceBus 中,当消息传入而没有匹配的传奇时,我该如何处理?

c# - 由 Bus.Publish() 或订阅引起的 StackOverflowException?

azure - 使用 Slack Webhook 的 Azure 警报无法正常工作

azure - Azure WebJob Sdk beta 0.5 中的 ServiceBusTrigger 批处理