Azure存储Java API:帐户不支持HTTP

时间:2017-06-13 17:39:38

标签: java azure azure-storage azure-java-sdk

我正在尝试使用Azure Storage Java API来检查存储容器是否存在,并且我看到以下异常。任何想法意味着什么?

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)

2 个答案:

答案 0 :(得分:10)

您使用SAS访问存储帐户吗?如果是这样,请确保您的SAS在生成时不包含“spr = https”。如果您使用存储密钥访问存储帐户,请在Azure门户上的存储帐户配置中将“需要安全传输”设置为“已禁用”:

enter image description here

答案 1 :(得分:1)

在连接到CloudStorageAccount时,将useHttps的值传递为true

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

将权限设置为

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 
});

都为我工作