question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] Spring Azure Cloud 4.4.1 Service Bus with stream binder results into AuthorizationFailed

See original GitHub issue

Describe the bug Spring Azure Cloud 4.4.1 Service Bus with stream binder results into AuthorizationFailed Exception or Stack Trace results into following error

NOTE: on different environment different object id is displayed in error

Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.azure.messaging.servicebus.ServiceBusClientBuilder]: Factory method 'serviceBusClientBuilder' threw exception; nested exception is java.lang.RuntimeException: Fetching ServiceBusNamespace with name '<some valid servicebus namespace>' failed due to: com.azure.core.management.exception.ManagementException: Status code 403, "{"error":{"code":"AuthorizationFailed","message":"The client '8f455a17-6010-45b5-9e6a-a39d74a64ac0' with object id '8f455a17-6010-45b5-9e6a-a39d74a64ac0' does not have authorization to perform action 'Microsoft.ServiceBus/namespaces/read' over scope '/subscriptions/<some valid subscription id>/resourceGroups/<some valid resource group>/providers/Microsoft.ServiceBus/namespaces/<some valid servicebus namespace>' or the scope is invalid. If access was recently granted, please refresh your credentials."}}": The client '8f455a17-6010-45b5-9e6a-a39d74a64ac0' with object id '8f455a17-6010-45b5-9e6a-a39d74a64ac0' does not have authorization to perform action 'Microsoft.ServiceBus/namespaces/read' over scope '/subscriptions/<some valid subscription id>/resourceGroups/<some valid resource group>/providers/Microsoft.ServiceBus/namespaces/<some valid servicebus namespace>' or the scope is invalid. If access was recently granted, please refresh your credentials.
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185)
	at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:653)
	... 19 common frames omitted
Caused by: java.lang.RuntimeException: Fetching ServiceBusNamespace with name '<some valid servicebus namespace>' failed due to: com.azure.core.management.exception.ManagementException: Status code 403, "{"error":{"code":"AuthorizationFailed","message":"The client '8f455a17-6010-45b5-9e6a-a39d74a64ac0' with object id '8f455a17-6010-45b5-9e6a-a39d74a64ac0' does not have authorization to perform action 'Microsoft.ServiceBus/namespaces/read' over scope '/subscriptions/<some valid subscription id>/resourceGroups/<some valid resource group>/providers/Microsoft.ServiceBus/namespaces/<some valid servicebus namespace>' or the scope is invalid. If access was recently granted, please refresh your credentials."}}": The client '8f455a17-6010-45b5-9e6a-a39d74a64ac0' with object id '8f455a17-6010-45b5-9e6a-a39d74a64ac0' does not have authorization to perform action 'Microsoft.ServiceBus/namespaces/read' over scope '/subscriptions/<some valid subscription id>/resourceGroups/<some valid resource group>/providers/Microsoft.ServiceBus/namespaces/<some valid servicebus namespace>' or the scope is invalid. If access was recently granted, please refresh your credentials.
	at com.azure.spring.cloud.resourcemanager.implementation.crud.AbstractResourceCrud.get(AbstractResourceCrud.java:62)
	at com.azure.spring.cloud.resourcemanager.implementation.connectionstring.ServiceBusArmConnectionStringProvider.getConnectionString(ServiceBusArmConnectionStringProvider.java:39)
	at com.azure.spring.cloud.core.implementation.factory.AbstractAzureServiceClientBuilderFactory.configureConnectionString(AbstractAzureServiceClientBuilderFactory.java:231)
	at com.azure.spring.cloud.core.implementation.factory.AbstractAzureServiceClientBuilderFactory.configureCore(AbstractAzureServiceClientBuilderFactory.java:152)
	at com.azure.spring.cloud.core.implementation.factory.AbstractAzureAmqpClientBuilderFactory.configureCore(AbstractAzureAmqpClientBuilderFactory.java:58)
	at com.azure.spring.cloud.core.implementation.factory.AbstractAzureServiceClientBuilderFactory.build(AbstractAzureServiceClientBuilderFactory.java:126)
	at com.azure.spring.cloud.autoconfigure.servicebus.AzureServiceBusClientBuilderConfiguration.serviceBusClientBuilder(AzureServiceBusClientBuilderConfiguration.java:50)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154)
	... 20 common frames omitted
Caused by: com.azure.core.management.exception.ManagementException: Status code 403, "{"error":{"code":"AuthorizationFailed","message":"The client '8f455a17-6010-45b5-9e6a-a39d74a64ac0' with object id '8f455a17-6010-45b5-9e6a-a39d74a64ac0' does not have authorization to perform action 'Microsoft.ServiceBus/namespaces/read' over scope '/subscriptions/<some valid subscription id >/resourceGroups/<some valid resource group>/providers/Microsoft.ServiceBus/namespaces/<some valid servicebus namespace>' or the scope is invalid. If access was recently granted, please refresh your credentials."}}"
	at java.lang.invoke.MethodHandle.invokeWithArguments(Unknown Source)
	at com.azure.core.implementation.http.rest.ResponseExceptionConstructorCache.invoke(ResponseExceptionConstructorCache.java:56)
	at com.azure.core.implementation.http.rest.RestProxyBase.instantiateUnexpectedException(RestProxyBase.java:377)
	at com.azure.core.implementation.http.rest.AsyncRestProxy.lambda$ensureExpectedStatus$1(AsyncRestProxy.java:117)
	at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onNext(FluxMapFuseable.java:113)
	at reactor.core.publisher.Operators$ScalarSubscription.request(Operators.java:2398)
	at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.request(FluxMapFuseable.java:171)
	at reactor.core.publisher.Operators$MultiSubscriptionSubscriber.set(Operators.java:2194)
	at reactor.core.publisher.Operators$MultiSubscriptionSubscriber.onSubscribe(Operators.java:2068)
	at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onSubscribe(FluxMapFuseable.java:96)
	at reactor.core.publisher.MonoJust.subscribe(MonoJust.java:55)
	at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:64)
	at reactor.core.publisher.MonoFlatMap$FlatMapMain.onNext(MonoFlatMap.java:157)
	at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onNext(FluxMapFuseable.java:129)
	at reactor.core.publisher.FluxHide$SuppressFuseableSubscriber.onNext(FluxHide.java:137)
	at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onNext(FluxMapFuseable.java:129)
	at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onNext(FluxMapFuseable.java:129)
	at reactor.core.publisher.FluxHide$SuppressFuseableSubscriber.onNext(FluxHide.java:137)
	at reactor.core.publisher.FluxMap$MapSubscriber.onNext(FluxMap.java:122)
	at reactor.core.publisher.FluxOnErrorResume$ResumeSubscriber.onNext(FluxOnErrorResume.java:79)
	at reactor.core.publisher.Operators$MonoSubscriber.complete(Operators.java:1816)
	at reactor.core.publisher.MonoFlatMap$FlatMapMain.onNext(MonoFlatMap.java:151)
	at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onNext(FluxMapFuseable.java:129)
	at reactor.core.publisher.Operators$MonoSubscriber.complete(Operators.java:1816)
	at reactor.core.publisher.MonoFlatMap$FlatMapMain.onNext(MonoFlatMap.java:151)
	at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.complete(MonoIgnoreThen.java:292)
	at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.onNext(MonoIgnoreThen.java:187)
	at reactor.core.publisher.Operators$MonoSubscriber.complete(Operators.java:1816)
	at reactor.core.publisher.MonoFlatMap$FlatMapInner.onNext(MonoFlatMap.java:249)
	at reactor.core.publisher.Operators$MonoSubscriber.complete(Operators.java:1816)
	at reactor.core.publisher.MonoFlatMap$FlatMapMain.onNext(MonoFlatMap.java:151)
	at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onNext(FluxMapFuseable.java:129)
	at reactor.core.publisher.Operators$MonoSubscriber.complete(Operators.java:1816)
	at reactor.core.publisher.MonoCollect$CollectSubscriber.onComplete(MonoCollect.java:160)
	at reactor.core.publisher.Operators$MonoSubscriber.complete(Operators.java:1817)
	at reactor.core.publisher.FluxCallable.subscribe(FluxCallable.java:49)
	at reactor.core.publisher.InternalMonoOperator.subscribe(InternalMonoOperator.java:64)
	at reactor.core.publisher.MonoFlatMap$FlatMapMain.onNext(MonoFlatMap.java:157)
	at reactor.core.publisher.SerializedSubscriber.onNext(SerializedSubscriber.java:99)
	at reactor.core.publisher.FluxRetryWhen$RetryWhenMainSubscriber.onNext(FluxRetryWhen.java:174)
	at reactor.core.publisher.FluxOnErrorResume$ResumeSubscriber.onNext(FluxOnErrorResume.java:79)
	at reactor.core.publisher.Operators$MonoInnerProducerBase.complete(Operators.java:2664)
	at reactor.core.publisher.MonoSingle$SingleSubscriber.onComplete(MonoSingle.java:180)
	at reactor.core.publisher.MonoFlatMapMany$FlatMapManyInner.onComplete(MonoFlatMapMany.java:260)
	at reactor.core.publisher.FluxMap$MapSubscriber.onComplete(FluxMap.java:144)
	at reactor.core.publisher.FluxDoFinally$DoFinallySubscriber.onComplete(FluxDoFinally.java:128)
	at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onComplete(FluxMapFuseable.java:152)
	at reactor.core.publisher.Operators$MonoSubscriber.complete(Operators.java:1817)
	at reactor.core.publisher.MonoCollect$CollectSubscriber.onComplete(MonoCollect.java:160)
	at reactor.core.publisher.FluxHandle$HandleSubscriber.onComplete(FluxHandle.java:220)
	at reactor.core.publisher.FluxMap$MapConditionalSubscriber.onComplete(FluxMap.java:275)
	at reactor.netty.channel.FluxReceive.onInboundComplete(FluxReceive.java:400)
	at reactor.netty.channel.ChannelOperations.onInboundComplete(ChannelOperations.java:419)
	at reactor.netty.channel.ChannelOperations.terminate(ChannelOperations.java:473)
	at reactor.netty.http.client.HttpClientOperations.onInboundNext(HttpClientOperations.java:703)
	at reactor.netty.channel.ChannelOperationsHandler.channelRead(ChannelOperationsHandler.java:93)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
	at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:436)
	at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:327)
	at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:299)
	at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:251)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
	at io.netty.handler.ssl.SslHandler.unwrap(SslHandler.java:1373)
	at io.netty.handler.ssl.SslHandler.decodeJdkCompatible(SslHandler.java:1236)
	at io.netty.handler.ssl.SslHandler.decode(SslHandler.java:1285)
	at io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:510)
	at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:449)
	at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:279)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357)
	at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379)
	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365)
	at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919)
	at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166)
	at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:722)
	at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:658)
	at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:584)
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:496)
	at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
	at java.lang.Thread.run(Unknown Source)
	Suppressed: java.lang.Exception: #block terminated with an error
		at reactor.core.publisher.BlockingSingleSubscriber.blockingGet(BlockingSingleSubscriber.java:99)
		at reactor.core.publisher.Mono.block(Mono.java:1707)
		at com.azure.resourcemanager.resources.fluentcore.arm.collection.implementation.GroupableResourcesImpl.getByResourceGroup(GroupableResourcesImpl.java:106)
		at com.azure.resourcemanager.resources.fluentcore.arm.collection.implementation.GroupableResourcesImpl.getByResourceGroup(GroupableResourcesImpl.java:28)
		at com.azure.spring.cloud.resourcemanager.implementation.crud.ServiceBusNamespaceCrud.internalGet(ServiceBusNamespaceCrud.java:35)
		at com.azure.spring.cloud.resourcemanager.implementation.crud.ServiceBusNamespaceCrud.internalGet(ServiceBusNamespaceCrud.java:15)
		at com.azure.spring.cloud.resourcemanager.implementation.crud.AbstractResourceCrud.get(AbstractResourceCrud.java:59)
		at com.azure.spring.cloud.resourcemanager.implementation.connectionstring.ServiceBusArmConnectionStringProvider.getConnectionString(ServiceBusArmConnectionStringProvider.java:39)
		at com.azure.spring.cloud.core.implementation.factory.AbstractAzureServiceClientBuilderFactory.configureConnectionString(AbstractAzureServiceClientBuilderFactory.java:231)
		at com.azure.spring.cloud.core.implementation.factory.AbstractAzureServiceClientBuilderFactory.configureCore(AbstractAzureServiceClientBuilderFactory.java:152)
		at com.azure.spring.cloud.core.implementation.factory.AbstractAzureAmqpClientBuilderFactory.configureCore(AbstractAzureAmqpClientBuilderFactory.java:58)
		at com.azure.spring.cloud.core.implementation.factory.AbstractAzureServiceClientBuilderFactory.build(AbstractAzureServiceClientBuilderFactory.java:126)
		at com.azure.spring.cloud.autoconfigure.servicebus.AzureServiceBusClientBuilderConfiguration.serviceBusClientBuilder(AzureServiceBusClientBuilderConfiguration.java:50)
		at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
		at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
		at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
		at java.lang.reflect.Method.invoke(Unknown Source)
		at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154)
		at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:653)
		at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:638)
		at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1352)
		at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1195)
		at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582)
		at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542)
		at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335)
		at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
		at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333)
		at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208)
		at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:955)
		at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918)
		at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583)
		at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:147)
		at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:734)
		at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:408)
		at org.springframework.boot.SpringApplication.run(SpringApplication.java:308)
		at org.springframework.boot.SpringApplication.run(SpringApplication.java:1306)
		at org.springframework.boot.SpringApplication.run(SpringApplication.java:1295)

To Reproduce

Code Snippet

spring.cloud.azure.credential.client-id=<some valid value>
spring.cloud.azure.credential.client-secret=<some valid value>
spring.cloud.azure.profile.tenant-id=<some valid value>
spring.cloud.azure.servicebus.namespace=<some valid value>
spring.cloud.azure.profile.subscription-id=<some valid value>
spring.cloud.azure.servicebus.resource.resource-group=<some valid value>

Expected behavior

Screenshots

Content (please complete the following information if possible):

Additional context

Information Checklist

  • Bug Description Added
  • Repro Steps Added
  • Setup information Added

Issue Analytics

  • State:closed
  • Created 10 months ago
  • Comments:13 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
saraglunacommented, Nov 14, 2022

@VarshaGadekar yes, we can provide that by requesting Azure Resource Manager (ARM) for the connection string. But this step requires the service principal to have management roles.

0reactions
saraglunacommented, Nov 24, 2022

I will close this issue now, please reopen it if you have any other questions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to use Spring Cloud Azure Stream Binder for Azure ...
This article demonstrates how to use Spring Cloud Stream Binder to send messages to and receive messages from Azure Service Bus.
Read more >
[BUG] When add spring-cloud-stream-binder-eventhubs or ...
Describe the bug When adding azure-spring-cloud-eventhubs-stream-binder or azure-spring-cloud-servicebus-queue-stream-binder ...
Read more >
Containerized springboot application not able to pick up new ...
The application is using "azure-spring-cloud-stream-binder-servicebus-queue" to connect to Azure Service Bus and process the queue.
Read more >
Spring Cloud Azure - Reference Documentation
... to Azure hosting services. This document is only for Spring Cloud Azure: 4.4.1. ... Starter for using Azure Service Bus and Spring...
Read more >
Spring Cloud Azure
Spring Cloud Stream Binder for Azure Event Hubs (native API and Apache Kafka API) · Spring Cloud Stream Binder for Azure Service Bus...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found