AzureStorage Blob服务器无法对请求进行身份验证.确保正确构成Authorization标头的值(包括签名) [英] AzureStorage Blob Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature
问题描述
我正在尝试在Windows Azure Blob中上传图像,但遇到了以下错误,我无法处理.
I'm trying to upload a image in Windows Azure Blob and I'm geting the following error which I can't handle.
服务器无法验证请求.请确保正确构成Authorization标头的值(包括签名).
Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.
尝试创建容器时发生错误.
The error occurs when I try to create a container.
container.CreateIfNotExists()
这是我的代码
try
{
Microsoft.WindowsAzure.Storage.CloudStorageAccount storageAccount = Microsoft.WindowsAzure.Storage.CloudStorageAccount.Parse(ConfigurationManager.AppSettings["StorageConnectionString"]);
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
// Retrieve a reference to a container.
CloudBlobContainer container = blobClient.GetContainerReference("samples");
// Create the container if it doesn't already exist.
// here is the error
if (container.CreateIfNotExists())
{
container.SetPermissions(
new BlobContainerPermissions
{
PublicAccess = BlobContainerPublicAccessType.Blob
});
}
CloudBlockBlob blockBlob = container.GetBlockBlobReference("Image1");
using (var fileStream = System.IO.File.OpenRead(@"Path"))
{
blockBlob.UploadFromStream(fileStream);
}
}
catch (StorageException ex1)
{
throw ex1;
}
我在代码中尝试了很多选项,但仍然收到错误消息.
I have tryied a lot of options in my code but still getting the error.
任何人都可以帮助我吗? 谢谢.
Anyone can please help me? Thanks.
推荐答案
我的PC的时间比其他人在注释中建议的少了1个小时.纠正它可以解决问题.
My PC's time was off by 1 hour as suggested by others in the comments. Correcting it solved the problem.
这篇关于AzureStorage Blob服务器无法对请求进行身份验证.确保正确构成Authorization标头的值(包括签名)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!