0
votes

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?

1
Please do not use Stack Snippets to add code if it is not a runnable HTML/CSS/JS code. I have changed the snippet to normal code blocks, corrected formatting and also improved some grammar. - Harry
anyone maybe help me :( - Harry

1 Answers

0
votes

Is this using the Java Client Library? If this works on your local machine but not on your Linux server it could have something to do with a caching proxy or something similar in between the client and the server. In any case, if you're seeing the same code work one place but not another, it seems likely that it is a configuration issue on your end and not a library bug.