我在 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/