Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

After release update from 6.0.4 to 6.1.0. , health check for Azure Service Bus Queue is broken. Throws Unauthorized access error. #1724

Closed
bhavsarravi opened this issue Mar 3, 2023 · 14 comments

Comments

@bhavsarravi
Copy link

bhavsarravi commented Mar 3, 2023

What happened: After release update from 6.0.4 to 6.1.0. , health check for Azure Service Bus Queue is broken. Throws Unauthorized access error.

What you expected to happen: We expect the same as how the AzureServiceBusQueue health check was working with least privilege Service Bus Sender Role as in 6.0.4 version.

How to reproduce it (as minimally and precisely as possible): Just provide with least privilege Service Bus Sender Role.
I attempted to implement a health check for a queue using an identity assigned the "Azure Service Bus Data Sender" role.

Source code sample:
image

Anything else we need to know?:

Exact Error Received:
[Error] [] Health check "catalog-servicebus-check" with status Unhealthy completed after 12744.2465ms with message 'null'System.UnauthorizedAccessException: Unauthorized access. 'Listen' claim(s) are required to perform this operation. Resource: 'sb://eus2-pind-sremark-atest.servicebus.windows.net/rdi-reportdata/$management'. TrackingId:11111111-2222-3333-4444-555555555555_G3, SystemTracker:NoSystemTracker, Timestamp:2023-03-02T02:47:07For troubleshooting information, see https://aka.ms/azsdk/net/servicebus/exceptions/troubleshoot.

  • .NET Core version 6.0
  • Healthchecks version 6.1.0
  • Operative system: Win
  • Others:
@sungam3r
Copy link
Collaborator

sungam3r commented Mar 3, 2023

See #1565 . Did you try the latest preview packages?

@bhavsarravi
Copy link
Author

Hi @sungam3r, I tried with new Pre release package 7.0.0-rc2.4, and it doesn't work. I get some weird error and it breaks the existing code.
However 6.0.4 version works perfectly fine with only "Azure Service Bus Data Sender" role and in 6.1.0 version due to this library change we need to provide additional role assignment of "Azure Service Bus Data Receiver".

@sungam3r
Copy link
Collaborator

sungam3r commented Mar 7, 2023

Would you like to post PR fixing it?

@marioleed
Copy link
Contributor

@sungam3r Latest prerelease package 7.0.0-rc2.4 doesn't seem to contain #1565.

@bhavsarravi When #1565 is released you should be able to use the new options parameter and set .UsePeekMode = false; and it should work as in 6.0.4.

services.AddHealthChecks()
    .AddAzureServiceBusQueue("example.servicebus.windows.net", "queueName", options => 
    {
        options.UsePeekMode = false;
    });

@sungam3r
Copy link
Collaborator

https://www.nuget.org/packages/AspNetCore.HealthChecks.AzureServiceBus/7.0.0-rc2.5

@marioleed
Copy link
Contributor

I have tested 7.0.0-rc5 and it seems to work as intended (with UsePeekMode = false) 👍🏻

@bhavsarravi
Copy link
Author

bhavsarravi commented Mar 15, 2023

I did tested version 7.0.0-rc2.5 using (with UsePeekMode = false) configurations and its working now.
Thank you so much for fixing it. Will be waiting to use it once released!

Note:
However it is observed that with this version there is a dependency require of library 'Microsoft.Bcl.AsyncInterfaces', which doesn't get added while installing this AspNetCore.HealthChecks.AzureServiceBus Nuget Package.

_Error : "FileNotFoundException: Could not load file or assembly 'Microsoft.Bcl.AsyncInterfaces, Version=7.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified.System.Reflection.CustomAttribute.CreateCaObject(RuntimeModule pModule, RuntimeType type, IRuntimeMethodInfo pCtor, Byte** ppBlob, Byte* pEndBlob, Int32* pcNamedArgs)"

This can be closed now!

@sungam3r
Copy link
Collaborator

#1692 (comment)

@sungam3r
Copy link
Collaborator

@bhavsarravi What is your TFM?

@marioleed
Copy link
Contributor

I actually get the same error in .NET 7 for .AddAzureEventHub():

Could not load file or assembly 'Microsoft.Bcl.AsyncInterfaces, Version=7.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified.

But not for .AddAzureServiceBus() 🤔

@sungam3r
Copy link
Collaborator

I have a feeling this dependency problem should be fixed by MS but in real world we can end up with spreading #1720 fix across all packages.

@sungam3r
Copy link
Collaborator

AzureEventHubHealthCheck calls ClientCache.GetOrAddAsyncDisposableAsync which explicitly uses IAsyncDisposable.

@sungam3r
Copy link
Collaborator

AddAzureServiceBus family of HCs do not use IAsyncDisposable explicitly so no error. Although they will suffer from the same bug if somewhere inside underlying packages they still use IAsyncDisposable.

@sungam3r
Copy link
Collaborator

sungam3r commented Jul 5, 2023

Closing as fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants