I have a bug related to Azure Blob storage when I use the below code to upload file to server Azure blob.
CloudStorageAccount account;
CloudBlobClient serviceClient;
CloudBlobContainer container;
CloudBlockBlob blob;
final String bucketName = PropertyReader.getValue("aws.properties", bucket);
account = CloudStorageAccount.parse(storageConnectionString);
serviceClient = account.createCloudBlobClient();
// Container name must be lower case.
container = serviceClient.getContainerReference(bucketName);
container.createIfNotExist();
// Set anonymous access on the container.
BlobContainerPermissions containerPermissions;
containerPermissions = new BlobContainerPermissions();
containerPermissions.setPublicAccess(BlobContainerPublicAccessType.CONTAINER);
container.uploadPermissions(containerPermissions);
// Upload an image file.
blob = container.getBlockBlobReference(imageName);
blob.upload(imageStream, imageArray.length);
I used that code and build on local host of mycomputer (Windows 8), it operates normally. But when I deploy to server linux it catch an exception
com.microsoft.windowsazure.services.core.storage.StorageException: Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.
I found this question on a related topic - Azure API The server failed to authenticate the request but it still did not help to resolve my problem. How do I fix this?