question

SyamalaUdayKumar-8831 avatar image
0 Votes"
SyamalaUdayKumar-8831 asked SeaMan-7944 answered

Microsoft.Azure.ServiceBus.UnauthorizedException

Getting the following error all of a sudden at the subscriber of a topic while reading message-
The issue is occurred earlier and it is resolved after a day without making any changes.

Haven't found any issues with the connection string, this is worked earlier and this error is occurring all of a sudden.

Microsoft.Azure.ServiceBus.UnauthorizedException
Put token failed. status-code: 401, status-description: Unauthorized TrackingId:460b83ec-0c8e-40fd-932d-eb8029a88190_G14

Failed Method : Microsoft.Azure.ServiceBus.Core.MessageReceiver+<OnReceiveAsync>d__88.MoveNext

Call Stack:
Microsoft.Azure.ServiceBus.UnauthorizedException:
at Microsoft.Azure.ServiceBus.Core.MessageReceiver+<OnReceiveAsync>d_88.MoveNext (Microsoft.Azure.ServiceBus, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7e34167dcc6d6d8c)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at Microsoft.Azure.ServiceBus.Core.MessageReceiver+<>c
DisplayClass65_0+<<ReceiveAsync>b0>d.MoveNext (Microsoft.Azure.ServiceBus, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7e34167dcc6d6d8c)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at Microsoft.Azure.ServiceBus.RetryPolicy+<RunOperation>d
19.MoveNext (Microsoft.Azure.ServiceBus, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7e34167dcc6d6d8c)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at Microsoft.Azure.ServiceBus.RetryPolicy+<RunOperation>d
19.MoveNext (Microsoft.Azure.ServiceBus, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7e34167dcc6d6d8c)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at Microsoft.Azure.ServiceBus.Core.MessageReceiver+<ReceiveAsync>d
65.MoveNext (Microsoft.Azure.ServiceBus, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7e34167dcc6d6d8c)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at Microsoft.Azure.ServiceBus.Core.MessageReceiver+<ReceiveAsync>d
63.MoveNext (Microsoft.Azure.ServiceBus, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7e34167dcc6d6d8c)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at Microsoft.Azure.ServiceBus.MessageReceivePump+<<MessagePumpTaskAsync>b
_12_0>d.MoveNext (Microsoft.Azure.ServiceBus, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7e34167dcc6d6d8c)

azure-service-bus
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

JayaC-MSFT avatar image
0 Votes"
JayaC-MSFT answered SyamalaUdayKumar-8831 commented

Hello @SyamalaUdayKumar-8831, Welcome to Microsoft QnA. Thank you for the question.

I am glad that your issue has been resolved. I see similar discussions which might help in this case:

https://www.pmichaels.net/tag/put-token-failed-status-code-401/
https://github.com/Azure/azure-service-bus/issues/182
https://stackoverflow.com/questions/43347605/event-hub-error-put-token-failed-status-code-401-status-description-expired/65534986#65534986

However, if you want a proper root cause analysis specific to your application, I would request you to open a support ticket with Microsoft Support if you have a subscription which allows you to do so. Otherwise ,you can send an email with subject line “Attn:Jaya” to AzCommunity[at]Microsoft[dot]com referencing this thread along with the subscription id.

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@JayaC-MSFT Thanks for the update.
The issue came back again. Not sure how t resolve this.

0 Votes 0 ·
SeaMan-7944 avatar image
0 Votes"
SeaMan-7944 answered

For me the issue "Put token failed. status-code: 401, status-description: Unauthorized" was caused by the networking configuration of the storage account where Azure Event Hub client persists checkpoints. Both the SA and EH have had whitelisted client address, and it works when I run client app from my laptop (behind the proxy btw). But when the same client deployed to AKS and acting through AKS egress public IP, even this IP whitelisted on the SA and EH, the EH accepts incoming connection, but the SA decline it. I am not sure where the AKS pod inciting connection from, no any logged connection attempts on the SA. When I made SA accept connections from "All networks", the issue "Put token failed. status-code: 401, status-description: Unauthorized" has gone. Microsoft has recommended to deploy SA into another region to have EH and SA in different regions, but I didn´t test it yet, and due to billed traffic I wouldn´t.
Hope this help.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.