4
votes

I have created a new WorkerRole using the template for a QueueWorkerRole in VS 2013 and it creates code that looks like this:

        // Create the queue if it does not exist already
        var connectionString = CloudConfigurationManager.GetSetting("Microsoft.ServiceBus.ConnectionString");
        var namespaceManager = NamespaceManager.CreateFromConnectionString(connectionString);
        if (!namespaceManager.QueueExists(QueueName))
        {
            namespaceManager.CreateQueue(QueueName);
        }

        // Initialize the connection to Service Bus Queue
        _client = QueueClient.CreateFromConnectionString(connectionString, QueueName);

The problem I ma having is setting the Microsoft.ServiceBus.ConnectionString correctly so that it will work with my local development queues running in the emulator. By default it sets it up like this:

<appSettings>
    <!-- Service Bus specific app setings for messaging connections -->
    <add key="Microsoft.ServiceBus.ConnectionString" value="Endpoint=sb://[your namespace].servicebus.windows.net;SharedSecretIssuer=owner;SharedSecretValue=[your secret]" />
</appSettings>

And I'm guessing this will work fine when I have a hosted service to connect to but I am just trying out some things locally and can't get it to connect.

I have tried "UseDevelopmentStorage=True" and I've tried using the address I found when viewing the Storage Emulator UI "127.0.0.1:10001" as well as the Local Emulator using Standard Format I found here: http://www.connectionstrings.com/windows-azure/ (DefaultEndpointsProtocol=https;AccountName=devstoreaccount1; AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;) but I am having no luck.

Sometimes I am seeing "The Service Bus connection string contains invalid property" in the Compute Emulator UI and other times I get an error that it can't connect.

Thanks.

1
Take a look at this thread: stackoverflow.com/questions/19300462/…. HTH.Gaurav Mantri
I don't see anywhere in that thread of the link provided that talks to using the local development emulator for the service bus queues. Unless I'm missing something.Jeff Treuting
I don't think there's an emulator for Service Bus (stackoverflow.com/questions/13087872/… / feedback.windowsazure.com/forums/216926-service-bus/suggestions/…). The connection string you're using above are for storage emulator which emulates Windows Azure Queues.Gaurav Mantri
Oh that makes sense. I think I am confused because you can create Queues in the Server Explorer of VS 2013 under Storage -> Development -> Queues. Thanks.Jeff Treuting

1 Answers

2
votes

The problem you are having here is that you are attempting to plug a queue connection string into a Service Bus Connection String Creator. Those two connection strings are inherently different.

To use development storage you need to set the value of the app setting key you wish to use to: "UseDevelopmentStorage=true" as seen in this stack overflow: Windows Azure Storage Emulator Connection String for ASP.NET MVC? This will work for STORAGE (not service bus)