Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AzureStorage Blob Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature

Tags:

blob

azure

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 tried a lot of options in my code but still getting the error.

like image 337
Fábio Henrique Avatar asked Jun 30 '14 14:06

Fábio Henrique


1 Answers

My PC's time was off by 1 hour as suggested by others in the comments. Correcting it solved the problem.

like image 95
Ashton Avatar answered Sep 28 '22 17:09

Ashton