azure-sdk-for-java icon indicating copy to clipboard operation
azure-sdk-for-java copied to clipboard

Cannot connect to Service Bus with Java using Azure Sample code

Open eleventy7 opened this issue 12 years ago • 8 comments

Hi,

Is there an issue with the connectivity via the Java SDK sample code? I cannot get basic connectivity to SB going.

Steps to reproduce:

  • Create a new service bus namespace in Azure, for example 'namespace'. I've tested multiple regions and find no difference in the outcome.

  • Get the necessary connection details from the Azure console

  • Enter these details into the example code (replacing namespace, key name, key value as needed), for example:

    Configuration config = ServiceBusConfiguration.configureWithWrapAuthentication( "namespace", "keyname", "keyvalue", ".servicebus.windows.net", "-sb.accesscontrol.windows.net/WRAPv0.9/");

  • Try run the ServiceBusService.create(config), and the following error is returned:

ServiceException encountered: com.sun.jersey.api.client.ClientHandlerException: java.net.UnknownHostException: namespace-sb.accesscontrol.windows.net

The error is in fact correct -- there is no such host. I've tried waiting for DNS propagation, but this did not seem to assist. I've tried multiple regions and this seemed to make no difference. What host name root (wrapRootUri is the field name) should we be using for this?

eleventy7 avatar Sep 16 '14 18:09 eleventy7

hi, shaunlaurens to use servicebus, you need to create a service bus from azure portal (https://manage.windowsazure.com), after you created servicebus, just use the access connection information from that created servicebus, such, namespace, key, keyvalue etc. to create your java servicebus client,

xuezhai avatar Sep 22 '14 18:09 xuezhai

The answer would probably be more useful if you actually read my question.

eleventy7 avatar Sep 22 '14 20:09 eleventy7

the current SDK works with service bus namespace with ACS auth mode, but not new created servicebus namespace which use SAS token auth mode. we will investigate this issue

xuezhai avatar Sep 24 '14 00:09 xuezhai

+1 - same issue. So what you are saying is the Java API is pretty much useless since you can't even create a service object??

knizami avatar Oct 10 '14 17:10 knizami

The team has triaged this issue and worked on it. We've also reached out to the service bus team on the change from ACS to SAS, and to our documentation team so that we have a full-stop plan for dealing with this change, as it's not just a code issue, it's a communication issue.

This fix will be in the next release of the Java SDK, based on everything I'm hearing from the team.

bradygaster-zz avatar Oct 17 '14 06:10 bradygaster-zz

One workaround is to create the service bus namespace via PowerShell. This seems to enable the ACS auth mode by default. Command is:

New-AzureSBNameSpace -Name MyNameSpace -Location "West Europe"

Take a note of the "DefaultKey" you get after running the command. You need to use that with the ServiceBusConfiguration and I'm not sure if that is available via the Azure management portal. Use "owner" as the authenticationName parameter to the configureWithWrapAuthentication.

juhap avatar Nov 08 '14 18:11 juhap

Just a note on that Juhap. Microsoft(Azure) are recommending people move to the SAS model for security) But it seems not all the libraries are up to date. There are a few threads around this topic on the net. If you pull down the latest version (0.8.10.1 Oct 2014) of powershell for azure , you need to pass a couple of other parameters to the cmd you mentioned above. I had to call like this:

New-AzureSBNamespace -name 'mynamespace' -location 'West US' -createACSNamespace $TRUE -NamespaceType Messaging

If you need help installing and configuring PS for azure go here (it is very simple) http://azure.microsoft.com/en-us/documentation/articles/install-configure-powershell/#Install

Bottle avatar Nov 09 '14 00:11 Bottle

Hi, @juhap & @Bottle - thank you, I can confirm that this now works.

eleventy7 avatar Nov 26 '14 17:11 eleventy7