Azure - 创建队列keep会返回"(400)错误请求"

Guy*_*she 4 azure azure-storage azure-queues

我试图用Azure创建一个新的存储队列,但它没有解释就一直崩溃,创建表工作正常,这是相关的代码:

        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.
        }
Run Code Online (Sandbox Code Playgroud)

代码崩溃符合healingQueue.CreateIfNotExists();解释(400) bad request

表创建得很好所以我假设存储帐户没有问题,我能做什么的想法?

Gau*_*tri 21

问题出现在以下代码行中:

healingQueue = queueClient.GetQueueReference("healQueue");
Run Code Online (Sandbox Code Playgroud)

基本上,您收到此错误的原因是您为队列选择了无效的名称.尝试使用healqueue(全部小写).

有关队列命名规则,请参阅此链接:https://msdn.microsoft.com/en-us/library/azure/dd179349.aspx.

  • 即使我在这段代码上工作了数百万年,我也永远不会想到这一点,到目前为止Azure还是令人沮丧(服务器可以返回类似"不允许大写字符"而不是"错误请求").无论如何,非常感谢,你救了我很多麻烦! (2认同)
  • 我同意你的看法,错误信息可能更具描述性.当您使用Azure进行更多操作时,如果从存储服务中收到400错误,请查找名称,数据类型和值.例如,看看这个帖子:http://stackoverflow.com/questions/14859405/azure-table-storage-returns-400-bad-request/ (2认同)