简体   繁体   中英

How to properly add health check for azure service bus when using managed identity (and rebus)

I have recently added managed identity support to Azure Service Bus and struggling how to properly add the health check. Prior to using managed identity, the health check was working fine, but now I am facing issues. The code to add the health check is the following:

                builder.AddAzureServiceBusQueue(
                    "myservicebus.servicebus.windows.net",
                    "myqueue",
                    new DefaultAzureCredential(),
                    name: $"Azure Service Bus Health Check");

With this code, I am receiving the following error:

Put token failed. status-code: 404, status-description: The messaging entity 'sb://myservicebus.servicebus.windows.net/myqueue/$management' could not be found. To know more visit https://aka.ms/sbResourceMgrExceptions . TrackingId:6bd6fac5-3fbd-4889-a89b-a4854b8299f9_G13, SystemTracker:myservicegus.servicebus.windows.net:myqueue/$management, Timestamp:2022-12-23T02:21:08. (MessagingEntityNotFound). For troubleshooting information, see https://aka.ms/azsdk.net/servicebus/exceptions/troubleshoot .

I am not sure what the $management is all about or why it is needed. I thought perhaps the role associated with managed identity was missing a capability. To test that, I granted the role "Azure Service Bus Data Owner" and "Owner" to the resource, but still receiving the above error.

Also, not sure if it matters, but I am using Rebus to handle the publishing and subscribing of events (with managed identity) and that is working fine.

Any help is appreciated.

Thanks, Eric

This is not really an answer, but here's some hopefully helpful information for anyone running into a similar issue.

The main mistake I had made was specifiying an incorrect queue name. It seems that when trying to perform the operation that health check is performing, something like:

   var receiver = client.CreateReceiver("the_invalid_queue");
   _ = await receiver.PeekMessageAsync().ConfigureAwait(false);

And when the queue name specified does not exist, we get the error as described in the question, mentioning the missing entity.

So just need to make sure to specify an existing queue name and all should work OK.

Eric

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM