使用以下代码(我对实际凭据进行了模糊处理):
CloudStorageAccount cloudStorageAccount = new CloudStorageAccount(new StorageCredentials(username, key), true);
CloudQueueClient clnt = cloudStorageAccount.CreateCloudQueueClient();
string logQueueReference = "log2";
CloudQueue queue = clnt.GetQueueReference(logQueueReference);
queue.CreateIfNotExists();
生成以下请求:
HEAD /log2?comp=metadata&timeout=90 HTTP/1.1
x-ms-version: 2012-02-12
User-Agent: WA-Storage/2.0.6.0
x-ms-date: Tue, 29 Apr 2014 13:26:29 GMT
Authorization: SharedKey username:transformedkey
Host: username.queue.core.windows.net
并返回以下回复:
HTTP/1.1 403 Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.
Transfer-Encoding: chunked
Server: Microsoft-HTTPAPI/2.0
x-ms-request-id: 0cc84a81-73e1-4a8c-bf16-098af2b21149
Date: Tue, 29 Apr 2014 15:26:29 GMT
我已经双重检查了凭据。它们是从manage.windowsazure.com的对话框中复制粘贴的。我在这里缺少什么?
答案 0 :(得分:8)
虽然此403错误的最常见原因是帐户密钥不正确(因此我会要求您再次检查)但是如果计算机上的时钟关闭(也称为clock skewness
),也可能出现此错误。请检查计算机上的时钟并确保它不会过多。有关详细信息,请参阅此主题:403 error in production from WindowsAzure.Storage。