azure-service-bus icon indicating copy to clipboard operation
azure-service-bus copied to clipboard

Getting the count of a Queue / Subscription (without admin string)

Open seanrmilligan opened this issue 4 years ago • 11 comments

Hi, I was hoping someone could point me in the right direction.

My team would like to get the count of the queues, subscriptions, and dead letter sub-queues that we read from. This would populate a dashboard so we can see the state of the queue/subscription over time.

My team is not the owner of the queue or topic; we have a connection string that allows us to dequeue but not enqueue. Therefore our connection string does not work with the Microsoft.Azure.ServiceBus.Management.ManagementClient class to get the MessageCountDetails. Instead we get this error message:

40100: Unauthorized : Unauthorized access for 'GetSubscription' operation on endpoint '[connection string]'

I think it should be possible to get the count of a queue without an admin connection string, but I can't find how.

Thanks, Sean

seanrmilligan avatar Oct 30 '19 19:10 seanrmilligan

To read the counts with the ManagementClient the connection string has to include the Manage policy.

SeanFeldman avatar Oct 30 '19 21:10 SeanFeldman

Is there a reason why this is the case? Understandably I would not want to hand out the Manage policy to anyone who subscribes to my topic.

And yet, without the Manage policy, a string with the Listen policy would be able to derive this information by repeatedly PeekAsyncing the queue and counting as it goes.

If the information is derivable by a Listen policy string then why gate it through a Manage policy?

seanrmilligan avatar Oct 30 '19 21:10 seanrmilligan

Is there a reason why this is the case?

@axisc can you help with that?

Another option to try is to look into Metrics.

SeanFeldman avatar Oct 30 '19 21:10 SeanFeldman

Receive permission ought to be enough to read the policy. /cc @binzywu, @axisc

clemensv avatar Nov 07 '19 08:11 clemensv

Thanks for giving this a bump, @clemensv.

@SeanFeldman I can definitely see Metrics working for the cases where we own the resource but we are a listener on some of the subscriptions in question we wouldn't be able to see those through Metrics. Thanks for the suggestion, though!

For consistency across Service Bus resources we own and resources we don't, my team has settled for emitting a metric in our application whenever we process or dead-letter something. This is more a measure of our message handling speeds than the size of the queue/subscription, but it will do.

I would suggest to the Service Bus team as @clemensv said: that as listeners on a queue/subscription we should be able to get some information about that queue/subscription, especially if that information is a derived property from our Listen permissions.

seanrmilligan avatar Nov 11 '19 03:11 seanrmilligan

I agree that it is both illogical and annoying that this Get operation requires the Manage policy (we are running in the same issue, where we want a service to be able to request the status of a subscription on a topic owned by another team, without handing it manage rights).

LucasReehorst avatar Feb 12 '21 11:02 LucasReehorst

Is this issue still relevant? If so, we will investigate the option to add a new API for this, as this currently part of the management plane.

EldertGrootenboer avatar Aug 05 '22 21:08 EldertGrootenboer

We have opened an investigation task for this in our backlog, and will update this issue when we have more information.

EldertGrootenboer avatar Aug 12 '22 21:08 EldertGrootenboer

Thank you for your feedback on this item, it helps us in our efforts to continuously prioritize the different requests we get from all our various feedback channels. We have added this feature in our backlog, however we currently don't have an ETA on when development might start on this. For now, to help us give this the right priority, it would be helpful to see others vote and support this feature, as well as explain their scenarios.

EldertGrootenboer avatar Oct 13 '23 19:10 EldertGrootenboer

We have the same problem.

Please make an api to count queue and subscriptions/topic that works with listener connection string.

We have added this feature in our backlog, however we currently don't have an ETA on when development might start on this. For now, to help us give this the right priority, it would be helpful to see others vote and support this feature, as well as explain their scenarios.

EldertGrootenboer avatar Apr 26 '24 17:04 EldertGrootenboer