Azure Storage Java API: Account does not support HTTP
Asked Answered
M

2

5

I am trying to use the Azure Storage Java API to check if a storage container exists and I am seeing the following exception. Any Idea what it means?

ERROR ~ com.microsoft.azure.storage.StorageException: The account being accessed does not support http.
105448         at com.microsoft.azure.storage.StorageException.translateFromHttpStatus(StorageException.java:211)
105449         at com.microsoft.azure.storage.StorageException.translateException(StorageException.java:172)
105450         at com.microsoft.azure.storage.core.StorageRequest.materializeException(StorageRequest.java:306)
105451         at com.microsoft.azure.storage.core.ExecutionEngine.executeWithRetry(ExecutionEngine.java:177)
105452         at com.microsoft.azure.storage.blob.CloudBlobContainer.exists(CloudBlobContainer.java:749)
105453         at com.microsoft.azure.storage.blob.CloudBlobContainer.exists(CloudBlobContainer.java:736)
105454         at com.microsoft.azure.storage.blob.CloudBlobContainer.exists(CloudBlobContainer.java:710)
105455         at com.scalegrid.cloudconnector.azure.AzureStorageClient.createContainerIfItDoesntExist(AzureStorageClient.java:255)
105456         at jobs.azurearm.machinepool.CreateCloudEntity.runStep(CreateCloudEntity.java:114)
105457         at jobs.Utils.ActionExecutor.<init>(ActionExecutor.java:84)
105458         at controllers.Clouds.createMachinePoolForAzureARM(Clouds.java:879)
105459         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
105460         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
105461         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
105462         at java.lang.reflect.Method.invoke(Method.java:497)
105463         at play.mvc.ActionInvoker.invokeWithContinuation(ActionInvoker.java:548)
105464         at play.mvc.ActionInvoker.invoke(ActionInvoker.java:502)
105465         at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:478)
105466         at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:473)
105467         at play.mvc.ActionInvoker.invoke(ActionInvoker.java:161)
105468         at play.server.PlayHandler$NettyInvocation.execute(PlayHandler.java:257)
105469         at play.Invoker$Invocation.run(Invoker.java:278)
105470         at play.server.PlayHandler$NettyInvocation.run(PlayHandler.java:235)
105471         at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
105472         at java.util.concurrent.FutureTask.run(FutureTask.java:266)
105473         at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
105474         at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
105475         at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
105476         at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
105477         at java.lang.Thread.run(Thread.java:745)
Musquash answered 13/6, 2017 at 17:39 Comment(0)
S
20

Are you using a SAS to access the storage account? If so, please ensure your SAS doesn't contain "spr=https" when being generated. If you're using storage key to access the storage account, please set "Secure transfer required" to Disabled in storage account configuration on Azure Portal:

enter image description here

Skirting answered 14/6, 2017 at 1:45 Comment(1)
I was about to answer the question :). I hope you don't mind me putting a bigger screenshot of "Enable/Disable Secure Transfer Required".Cerium
C
2

Pass the value as true for useHttps, while connecting to CloudStorageAccount

CloudStorageAccount(
    StorageCredentials storageCredentials, 
    string accountName, 
    string endpointSuffix, 
    bool useHttps
)

Or

set the permissions as,

CloudStorageAccount storageAccount =
    CloudStorageAccount.Parse(settings.StorageAccountConnectionString);

//Client
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();

CloudBlobContainer blobContainer = 
    blobClient.GetContainerReference(settings.ContainerName);

await blobContainer.SetPermissionsAsync(new BlobContainerPermissions() {
    PublicAccess = BlobContainerPublicAccessType.Blob 
});

Both worked for me

Christinachristine answered 11/2, 2019 at 12:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.