I’m totally new with Azure Service Bus, and just for studing I’m trying to get topics. If I’m not wrong I should use class ServiceBusAdministrationClient
but when I tried to achieve my goal I got the error "InvalidSignature: The token has an invalid signature".
I’m using the easiest constructor (https://learn.microsoft.com/en-us/dotnet/api/azure.messaging.servicebus.administration.servicebusadministrationclient.-ctor?view=azure-dotnet#azure-messaging-servicebus-administration-servicebusadministrationclient-ctor(system-string) ) passing the same connectionString that allows me to send and receive messages using ServiceBusClient
.
Theorically I should be able to do that using the same connection string, I think that because the Service Bus Explorer developed by Paolo Salvatori (https://github.com/paolosalvatori/ServiceBusExplorer) is able to do that with the same connection string. Am I wrong or do I need a different connection string?
Here the code I have (copied from another post):
var administrationClient = new ServiceBusAdministrationClient(ConnectionString);
AsyncPageable<TopicProperties> allTopics = administrationClient.GetTopicsAsync();
await foreach (TopicProperties topic in allTopics)
{
Console.WriteLine($"IterateTopicsWithAwaitForeachAsync: {topic.Name}");
}
Can anyone please explain me what I’m doing wrong?
ps. I’m using .net 8
2
Answers
This code is working fine. I’d double-check your connection string. Also, it is worth noting that the administrative client works via HTTP while the data client works via AMQP by default. So, there might be a chance that your data operations are working while management operations fail if HTTP traffic is blocked.
Thanks @Sean Feldman and I do agree that there might be a chance of Traffic being blocked otherwise if you give correct connection string, it will work and I have taken connection string from below:
The topics i have are:
With
Azure.Messaging.ServiceBus.Administration
package(ServiceBusAdministrationClient) :Output:
Alterantively you can use
Microsoft.Azure.ServiceBus.Management
package(ManagementClient) :Output: