Tod Cunningham
Tod Cunningham

Reputation: 3709

Azure Website Connection to a ServiceBus Queue remote name could not be resolved

I have a simple Azure website (PaaS website) that is trying to connect to a Service Bus queue. However, it is getting the error:

[WebException: The remote name could not be resolved: 'XXXXXXXXX-sb.accesscontrol.windows.net']
System.Net.HttpWebRequest.GetRequestStream(TransportContext& context) +6543605 System.Net.HttpWebRequest.GetRequestStream() +13 Microsoft.ServiceBus.TokenProviderHelper.GetAccessTokenCore(Uri requestUri, String appliesTo, String requestToken, String simpleAuthAssertionFormat, TimeSpan timeout, String& expiresIn, String& audience) +617

Any ideas on how to resolve this error? It's looking like a permissions issue, but I'm new to Azure and I'm not seeing how to fix it. It's using the service busses "RootManageSharedAccessKey" that has Manage, Send, and Listen permissions.

I also have a worker role setup that is able to access the queue, so I know the queue is there. I can also use Visual Studio to send a test message to the queue and it is received by the worker. I just can't get the front end azure website to access it.

Upvotes: 3

Views: 3086

Answers (2)

Tod Cunningham
Tod Cunningham

Reputation: 3709

I changed how I was connecting to the service bus. The problem was related to not passing in the correct values to the NamespaceManager. I ended up using the following to connect to the Service bus:

    // By default when connecting to the queue we will look at the appSettings for they key "Microsoft.ServiceBus.ConnectionString"
    //
    //  <appSettings>
    //    <add key="Microsoft.ServiceBus.ConnectionString" value="Endpoint=sb://XXXXXXXXXX.servicebus.windows.net;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=XXXXXXXXXXXXXXXXXXXXXXXXXXX" />
    //  </appSettings>
    //
    public TachyonQueueClient(String queueName, String appSettingKey = "Microsoft.ServiceBus.ConnectionString")
    {
        name = queueName;

        string connectionString = CloudConfigurationManager.GetSetting(appSettingKey);
        namespaceManager = NamespaceManager.CreateFromConnectionString(connectionString);
        if (!namespaceManager.QueueExists(queueName))
        {
            namespaceManager.CreateQueue(queueName);
        }

        // Initialize the connection to Service Bus Queue
        client = QueueClient.CreateFromConnectionString(connectionString, queueName);
    }

Upvotes: 2

Padma Aradhyula
Padma Aradhyula

Reputation: 201

Did you create a new service bus namespace from azure portal recently? There has been a change made where the default authentication mechanism is SAS and no ACS namespaces are provisioned automatically.

Please refer to this blog which has details on this issue http://blogs.msdn.com/b/servicebus/archive/2014/09/03/change-to-azure-service-bus-portal-default-authentication-mechanism-for-service-bus-namespaces-now-sas.aspx

Upvotes: 2

Related Questions