When i am trying create container for my storage i get StorageException. 1.I created azure account. 2.I created azure storage for blob 3.I wrotten simple test(below) 4.I made this code on local machine and got exception. What is wrong?
public class Test {
public static final String storageConnectionString =
"DefaultEndpointsProtocol=https;" +
"AccountName=my_account;" +
"AccountKey=my_account_key";
public static void main(String[] args) throws StorageException, InvalidKeyException, URISyntaxException {
pushControll();
}
public static void pushControll() throws URISyntaxException, StorageException, InvalidKeyException {
CloudStorageAccount storageAccount = CloudStorageAccount.parse(storageConnectionString);
CloudBlobClient blobClient = storageAccount.createCloudBlobClient();
CloudBlobContainer container = blobClient.getContainerReference("observer");
container.create();
}
}
I get StorageException - >:
Exception in thread "main" com.microsoft.azure.storage.StorageException: Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.
at com.microsoft.azure.storage.StorageException.translateException(StorageException.java:89)
at com.microsoft.azure.storage.core.StorageRequest.materializeException(StorageRequest.java:307)
at com.microsoft.azure.storage.core.ExecutionEngine.executeWithRetry(ExecutionEngine.java:182)
at com.microsoft.azure.storage.blob.CloudBlobContainer.create(CloudBlobContainer.java:279)
at com.microsoft.azure.storage.blob.CloudBlobContainer.create(CloudBlobContainer.java:252)
at ru.marketirs.model.Test.pushControll(Test.java:40)
at ru.marketirs.model.Test.main(Test.java:25)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Process finished with exit code 1
What have i done wrong?
Your code looks ok to me. Please check for 2 things: 1) Make sure that the account name/key is proper and 2) Check the clock on your computer and see if it is running slow. These 2 things could cause the error you're getting.
To by pass the proxy then please use like below, it works as expected and same has been tested.
.Net or C# then please add below code to "App.config"