如何使用托管身份通过 Java 向服务总线进行身份验证

How to use a managed identity to authenticate to a service bus using Java

我正在尝试使用用户分配的托管标识让我的应用程序连接到我的服务总线。我现在在 Quarkus 中使用 Apache Qpid,我们正在使用连接字符串进行连接。

有谁知道应该怎么做?我没有在 Quarkus 或 Qpid 文档中看到任何示例如何做。

谢谢 Jesse Squire,发布您的答案以帮助其他社区成员。

DefaultAzureCredential is a chained credential; internally it considers multiple authorization sources, including managed identities. More information can be found in the Azure.Identity overview.

Service Bus can use any of the Azure.Identity credentials for authorization. DefaultAzureCredentialBuilder is demonstrated only because it allows for success in a variety of scenarios.

If you'd prefer to restrict authorization to only a managed identity, you can do so by using ManagedIdentityCredentialBuilder rather than the default credential. An example of creating the can be found here. It can then be passed to Service Bus in the same manner as the default credential.

更多信息请参考Authenticate a managed identity with Azure Active Directory, SO threads , 2