2

Is there any way to just ping the service bus using queueClient. Or just check whether we are able to connect to service bus without manipulating the messages. Microsoft Azure, c#

Jyotsna
  • 49
  • 1
  • 4
  • Yes there is. What have you thought of? – Peter Bons May 10 '18 at 06:49
  • 1
    Really, is there? It would be very useful to be able to do it, so you can check the access to the Queue (e.g. as a health check). But as far as I know, you can't easily do it without highly elevated permissions (i.e. authenticate as a Service Principal). Or do you know about any elegant way @PeterBons? – Marcel Toth Jul 23 '18 at 18:15

1 Answers1

3

Or just check whether we are able to connect to service bus without manipulating the messages

If you want to check the servicebus queue status, we could use WindowsAzure.ServiceBus

The following is the demo code.

string connectionString = "connection string";
var namespaceManager = NamespaceManager.CreateFromConnectionString(connectionString);
var queueDescription = namespaceManager.GetQueue("queue name");
var status = queueDescription.Status;

enter image description here

Tom Sun - MSFT
  • 24,161
  • 3
  • 30
  • 47
  • That's not a guarantee that you can read/write from the queue, right? I guess a better test would be a proper end-to-end one with a test queue where you would place a message then read it back. – evilSnobu May 11 '18 at 05:39
  • 2
    `Or just check whether we are able to connect to service bus without manipulating the messages.` Based on my understanding, OP don't want to test it with a message. Just want to check whether we are able to connect to service bus. – Tom Sun - MSFT May 11 '18 at 05:42
  • 1
    Right, saw that, then i guess my question is more for the OP. – evilSnobu May 11 '18 at 05:43
  • When I go to the trouble of creating a QueueDescription, I go ahead and get some values, and throw them into a DTO object. https://learn.microsoft.com/en-us/dotnet/api/microsoft.servicebus.messaging.messagecountdetails?view=azure-dotnet – granadaCoder Aug 20 '19 at 19:33
  • myDto.ActiveMessageCount = qd.MessageCountDetails.ActiveMessageCount; myDto.DeadLetterMessageCount = qd.MessageCountDetails.DeadLetterMessageCount; myDto.ScheduledMessageCount = qd.MessageCountDetails.ScheduledMessageCount; myDto.TransferDeadLetterMessageCount = qd.MessageCountDetails.TransferDeadLetterMessageCount; myDto.TransferMessageCount = qd.MessageCountDetails.TransferMessageCount; – granadaCoder Aug 20 '19 at 19:33
  • But upvote, because I am going to add Status to my myDto object. As per the documentation, it looks like it can tell you "writeable" : https://learn.microsoft.com/en-us/dotnet/api/microsoft.servicebus.messaging.queuedescription.status?view=azure-dotnet#Microsoft_ServiceBus_Messaging_QueueDescription_Status – granadaCoder Aug 20 '19 at 19:36