Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure - Creating a queue keep returns "(400) bad request"

I am trying to simply create a new Storage Queue with Azure but it keeps crash without explanation, creating tables worked just fine, this is the relevant code:

        private CloudTable userTable;
        private CloudTable petTable;
        private CloudQueue healingQueue;

        public override bool OnStart()
        {
            CloudStorageAccount storageAccount = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("connectionString"));
            CloudTableClient tableClient = storageAccount.CreateCloudTableClient();
            userTable = tableClient.GetTableReference("users");
            userTable.CreateIfNotExists();
            petTable = tableClient.GetTableReference("pets");
            petTable.CreateIfNotExists();

            // This is where I create the queue: //
            CloudQueueClient queueClient = storageAccount.CreateCloudQueueClient();
            healingQueue = queueClient.GetQueueReference("healQueue");
            healingQueue.CreateIfNotExists(); // This line makes the code crash.
        }

Code crashes in line healingQueue.CreateIfNotExists(); with the explanation of (400) bad request

Tables are created just fine so I assume there is no problem with the storage account, any ideas what I can do?

like image 552
Guy Ben-Moshe Avatar asked Jan 16 '16 10:01

Guy Ben-Moshe


1 Answers

The problem is in the following line of code:

healingQueue = queueClient.GetQueueReference("healQueue");

Essentially the reason you're getting this error is because you are choosing an invalid name for a queue. Try using healqueue (all lowercase).

Please see this link for Queue naming rules: https://msdn.microsoft.com/en-us/library/azure/dd179349.aspx.

like image 117
Gaurav Mantri Avatar answered Oct 20 '22 10:10

Gaurav Mantri