Azure 存储:403 服务器无法对请求进行身份验证 [英] Azure Storage: 403 Server failed to authenticate the request
问题描述
我已经在此处和 Google 中搜索过,但找不到解决方案.
I've search here and in Google but I can't find a solution.
我想使用我的 C# 代码从 Azure 存储 Blob 读取文件.该代码(仅 6 行)在另一个项目(Windows 8.1 通用应用程序)中运行良好,但不适用于我的新 Windows 10 UWP 应用程序.
With my C# code I want to read a file from Azure Storage Blob. The code (only 6 line) works very well in another project (Windows 8.1 Universal App) but not in my new Windows 10 UWP App.
这是我的代码:
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(azureConnectionString);
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
CloudBlobContainer container = blobClient.GetContainerReference("container-name");
CloudBlob b1 = container.GetBlobReference("27.76914.json");
StorageFile file = await ApplicationData.Current.LocalFolder.CreateFileAsync("stefano1.json", CreationCollisionOption.ReplaceExisting);
await b1.DownloadToFileAsync(file);
例外:
服务器无法验证请求.确保值正确形成授权标头,包括签名.
Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.
使用 Fiddler4 我在消息 403 上发现了这个错误:
在 HTTP 请求 'R2t9hKsyXf470HF2LNP8T+M2nci0ddE/ojQ0r4UVjJQ=' 中发现的 MAC 签名与任何计算签名都不相同
The MAC signature found in the HTTP request 'R2t9hKsyXf470HF2LNP8T+M2nci0ddE/ojQ0r4UVjJQ=' is not the same as any computed signature
我的尝试:
- 应用程序第一次运行(下载文件).我第二次收到异常.
- 如果我更改了请求的文件名:应用程序第一次运行(文件下载).我第二次收到异常.
- 第二天我立即得到同样的异常(第一次运行时)
- 另外,如果我删除 bin 和 obj 文件夹,我会收到错误
- 如果我创建另一个应用程序并尝试下载相同的文件(与第 1 点相同),它会在第一次运行,但在第二次无法运行.
- 在控制台应用程序中一切正常.
这是 Fiddler4 原始请求(其中 ***** 是我的 Azure 存储帐户名称):
This is the Fiddler4 Raw Request (where ***** is my Azure Storage Account Name):
GET https://*****.blob.core.windows.net/container-name/27.76914.json HTTP/1.1
x-ms-client-request-id: accee7e7-646d-417a-b734-1591cbc16a8d
x-ms-date: Thu, 03 Sep 2015 06:31:37 GMT
x-ms-version: 2015-02-21
User-Agent: WA-Storage/5.0.2 (Windows Runtime)
Authorization: SharedKey *****:R2t9hKsyXf470HF2LNP8T+M2nci0ddE/ojQ0r4UVjJQ=
Host: *****.blob.core.windows.net
If-Modified-Since: Sun, 30 Aug 2015 18:52:41 GMT
If-None-Match: "0x8D2B16C2ED82C4A"
Connection: Keep-Alive
谢谢!
推荐答案
这也在我们的 GitHub 页面上报告:https://github.com/Azure/azure-storage-net/issues/171
This was also reported on our GitHub page here: https://github.com/Azure/azure-storage-net/issues/171
我们的主要理论是缓存代理可能位于客户端和服务器之间,影响您的请求.
Our leading theory is that a caching proxy might be in between the client and the server affecting your requests.
我们仍在调查中,会通知您.
We're still investigating and will let you know.
这篇关于Azure 存储:403 服务器无法对请求进行身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!