问题
I'm trying to upload a image in Windows Azure Blob and I'm geting the following error which I can't handle.
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()
Here is my code
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.
回答1:
My PC's time was off by 1 hour as suggested by others in the comments. Correcting it solved the problem.
回答2:
in my case it was actually the shared access signature (SAS) that expired. updating (actually making a new one) the shared access signature in portal.azure.com by adding a year (or more) for end date in the future. And all problems fixed.
回答3:
I got this message when I was trying to access BLOB Storage through REST API Endpoint.
Below is the response that I got when invoked list container operation with Authorization header
<?xml version="1.0" encoding="utf-8"?>
<Error>
<Code>AuthenticationFailed</Code>
<Message>Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.
RequestId:096c6d73-f01e-0054-6816-e8eaed000000
Time:2019-03-31T23:08:43.6593937Z</Message>
<AuthenticationErrorDetail>Authentication scheme Bearer is not supported in this version.</AuthenticationErrorDetail>
</Error>
solution was to include below header
x-ms-version: 2017-11-09
回答4:
Check the timezone of your computer or mobile phone.
回答5:
In my case I was passing storage connection string with access signature as an argument to console application. '%' in command line is an special character 'command line parameters'. '%' appears in access signature (SAS). You have to escape percent %, double it %%.
回答6:
I am using .NET SDK for Azure blob file uploading with metadata. I got an error while uploading files into Azure Blob storage with metadata, the error is "Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature." But these errors were only a few files not all of them.
Issue here If you have metadata for the file, metadata should not contain special characters(�) or additional space( ) starting of the value and end of the value.
If you correct the metadata values then the file will upload successfully.
来源:https://stackoverflow.com/questions/24492790/azurestorage-blob-server-failed-to-authenticate-the-request-make-sure-the-value