【问题标题】:com.microsoft.windowsazure.services.core.storage.StorageException: Server failed to authenticate the requestcom.microsoft.windowsazure.services.core.storage.StorageException:服务器未能对请求进行身份验证
【发布时间】:2016-04-04 07:54:13
【问题描述】:

当我使用以下代码将文件上传到服务器 Azure Blob 时,我遇到了与 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);

我使用该代码并在我的计算机(Windows 8)的本地主机上构建,它运行正常。但是当我部署到服务器 linux 时,它会捕获一个异常

com.microsoft.windowsazure.services.core.storage.StorageException:服务器未能对请求进行身份验证。确保 Authorization 标头的值格式正确,包括签名。

我在一个相关主题上发现了这个问题 - Azure API The server failed to authenticate the request 但它仍然无助于解决我的问题。我该如何解决这个问题?

【问题讨论】:

  • 如果不是可运行的 HTML/CSS/JS 代码,请不要使用 Stack Snippets 添加代码。我已将 sn-p 更改为普通代码块,更正了格式并改进了一些语法。
  • 任何人都可以帮助我:(

标签: azure blob


【解决方案1】:

这是使用 Java 客户端库吗?如果这在您的本地计算机上有效,但在您的 Linux 服务器上无效,则可能与缓存代理或客户端和服务器之间的类似内容有关。在任何情况下,如果您看到相同的代码在一个地方工作,但在另一个地方却没有,这似乎是您的配置问题,而不是库错误。

【讨论】:

  • 你好彼得。我需要什么来配置代理客户端或服务器。你能帮助我吗。 ?
  • 你需要确保你的客户端和你的服务器之间没有缓存——我不知道你是如何配置这些部分的。如果您可以为失败的请求提供请求 ID,我可以再看一下,但这是我的猜测。
猜你喜欢
  • 2020-01-29
  • 2014-09-19
  • 1970-01-01
  • 2016-01-31
  • 2016-11-18
  • 1970-01-01
  • 2015-11-28
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多