Search code examples
javaspringspring-bootazureazureservicebus

Use managed identity with azure service bus messaging


I have been trying to Spring Messaging Azure Service Bus (as described here) with a managed identity. However, I get a bunch of error messages from ChainedTokenCredential, including "Azure Identity => Attempted credential ManagedIdentityCredential is unavailable". I tried setting managed-identity-enabled: true and client-id in spring. cloud.azure.servicebus.credential..., or cloud.azure.servicebus.producer.credential...

With the Spring Cloud Azure Service Bus Starter it worked fine, but I would prefer to use the messaging features to be able to interact with multiple queues.


Solution

  • In case anyone else faces the same issue: when using the spring-messaging-azure-servicebus library, even though properties like spring.cloud.azure.servicebus.credential.client-id are valid (since they are part of the generic azure autoconfigure package), aren't actually used. It does work however if you set AZURE_CLIENT_ID as an env variable.