2

I have written and successfully deployed a test app to the azure cloud, but I am lost now that I have added a queue to the application.

Currently I using a configuration string:

Setting name="DataConnectionString" value="UseDevelopmentStorage=true" 

then create/open the queue with the following code:

var storageAccount = CloudStorageAccount.FromConfigurationSetting("DataConnectionString");
var queueClient = storageAccount.CreateCloudQueueClient();
var queue = queueClient.GetQueueReference("messagequeue");
queue.CreateIfNotExist();

This works fine in local mode, however, I do not undertsand how to change the DataConnectionString to use the cloud!

I have tried:

Setting name="DataConnectionString" value="DefaultEndpointsProtocol=http;AccountName=*XXXXX*;AccountKey=*YYYYY*"

but this does not work - it wont run locally. Help is certainly appreciated!

Thanks

sebagomez
  • 9,501
  • 7
  • 51
  • 89
user611304
  • 21
  • 2

1 Answers1

3

You'll need to make sure you've created a hosted azure storage service via the Windows Azure portal. When creating the storage service, you provide the account name and the system will assign two keys. Use these two values in your connection string settings. You can either manually edit the string in the service configuration, or my preferred approach is to set it via the role's property settings. Simply right click on the role in the cloud service project in visual studio, then select properties. You'll be able to access the role's settings via one of the tabs. Use the provided dialog box to modify the connection string by inputing the account name and connection string for your storage service.

BrentDaCodeMonkey
  • 5,493
  • 20
  • 18
  • ...and what's nice about this, is that you can use your "real" Storage Service even while testing your app locally. My suggestion is to change this data connection string to your Azure-hosted storage "before" deploying your app to Azure. Note: If you deploy your app to Azure and the storage account connection string still points to "UseDevelopmentStorage=true" - you'll find that your Azure deployment throws an exception. – David Makogon Feb 10 '11 at 14:13
  • Actually I think the exception we used to get for this (due to Azure Diagnostics trying to access the non-existant storage service) is now surpressed. You'll still get an exception in the app when you programatically try to access storage for other reasons though. – BrentDaCodeMonkey Feb 10 '11 at 18:06