DDovzhenko
DDovzhenko

Reputation: 1315

Java Azure SB Connection with SAS token

ServiceBusConfiguration.configureWithSASAuthentication(config.getSbNamespace(), "RootManageSharedAccessKey", SAS_KEY, ".servicebus.windows.net");
ServiceBusContract service = ServiceBusService.create();
service.getTopic(topicID);

This code snippet is used to connect to Service Bus using SAS Key. I'm looking for possibility of connection with SAS token which looks like this:

SharedAccessSignature sr=https%3a%2f%2fmynamespace.servicebus.windows.net%2fMyTestQueue&sig=fFWmdMmWjsdTqPyhyvRS9LQqLjJNPc87xhInhYai9OM%3d&se=1453286209&skn=MyQueue_Listen

I receive 401 Unauthorized using this code. I don't have possibility to go back to SAS key. Does Azure SDK for Java support this? Is there different way to connect?

Upvotes: 1

Views: 403

Answers (2)

Peter Pan
Peter Pan

Reputation: 24148

It sounds like you want to use Azure Service Bus SDK for Java to do something like to get a topic via topic id, but you didn't know how to pass the shared access key to the method configureWithSASAuthentication.

I suggested that you need to follow the offical tutorial How to use Service Bus topics and subscriptions carefully to know how to get the shared access key for a service bus instance and to use it via SDK.

enter image description here

The SharedAccessSignature sr=https%3a%2f%2fmynamespace.servicebus.windows.net%2fMyTestQueue&sig=fFWmdMmWjsdTqPyhyvRS9LQqLjJNPc87xhInhYai9OM%3d&se=1453286209&skn=MyQueue_Listen that you were looking for is for calling the related REST APIs, not directly used in the code with SDK.

Hope it helps.

Upvotes: 1

Sean Feldman
Sean Feldman

Reputation: 26012

The ".servicebus.windows.net" looks a bit off (the . in the beginning).

FYI: There's an ASB Java client repository repository with issue tracker. You could check there as well.

Upvotes: 1

Related Questions