2
votes

Trying to connect to a windows azure queue from a windows service (ie. not running in azure, just on my desktop, for now, but eventually on a self-hosted windows server).

The connection string generated by the dashboard is in the following form:

Endpoint=sb://MyServiceBus.servicebus.windows.net/;SharedAccessKeyName=MySasName;SharedAccessKey=*****

I'm trying to initialize the CloudStorageAccount, but am receiving a format exception (as noted in the title).

string str = ConfigurationManager.AppSettings["StorageConnectionString"];
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(
            str);

This seems to match all of the documentation ... can anyone clear up what might be going on?

Are you trying to use storage queues or service bus queues? The 1st connection string is for service bus queue. You won't be able to initialize your storage account connection using that string.Gaurav Mantri
This is a service bus queue. I configured it by creating a service bus, and then adding a queue. This is the connection string that I get when I view the queue in the dashboard. Should I be using a different API?Joel Martinez
Yes. As mentioned in my comment above, using this connection string you won't be able initialize your storage account connection string. Your storage account connection string should be in this format: DefaultEndpointsProtocol=https;AccountName=[account name];AccountKey=[account key]. You can get account name/key from Windows Azure Portal. HTH.Gaurav Mantri
Hi @GauravMantri, thanks for the help, it's able to parse it correctly now. Perhaps I'm using the incorrect values, but now I'm just getting a 403 when I try to pull a message from the queue. Where in the dashboard can I verify that I'm using the correct accountname and accountkey? I'd assumed it's from the queue settings screen where they are labeled: "Policy Name", and "Primary Key".Joel Martinez
For storage accounts, if you click on the storage account name in the portal and click on the "Manage Keys" button, it will show you the account key.Gaurav Mantri