我正在尝试在Windows Azure Blob中上传图像,并且我发现以下错误,我无法处理.
服务器无法验证请求.确保正确形成Authorization标头的值,包括签名.
我尝试创建容器时发生错误.
container.CreateIfNotExists()
Run Code Online (Sandbox Code Playgroud)
这是我的代码
try
{
Microsoft.WindowsAzure.Storage.CloudStorageAccount storageAccount = Microsoft.WindowsAzure.Storage.CloudStorageAccount.Parse(ConfigurationManager.AppSettings["StorageConnectionString"]);
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
// Retrieve a reference to a container.
CloudBlobContainer container = blobClient.GetContainerReference("samples");
// Create the container if it doesn't already exist.
// here is the error
if (container.CreateIfNotExists())
{
container.SetPermissions(
new BlobContainerPermissions
{
PublicAccess = BlobContainerPublicAccessType.Blob
});
}
CloudBlockBlob blockBlob = container.GetBlockBlobReference("Image1");
using (var fileStream = System.IO.File.OpenRead(@"Path"))
{
blockBlob.UploadFromStream(fileStream);
}
}
catch (StorageException ex1)
{
throw ex1;
}
Run Code Online (Sandbox Code Playgroud)
我在我的代码中尝试了很多选项,但仍然遇到错误.
有人可以帮我吗?谢谢.
Ash*_*ton 11
其他人在评论中建议,我的电脑时间缩短了1个小时。纠正它可以解决问题。
小智 11
我正在使用 .NET SDK 上传带有元数据的 Azure blob 文件。使用元数据将文件上传到 Azure Blob 存储时出现错误,错误是“服务器无法对请求进行身份验证。确保正确形成授权标头的值,包括签名。” 但是这些错误只是几个文件而不是全部。
此处问题 如果您有文件的元数据,元数据不应包含特殊字符 (?) 或额外的空格 ( ) 开头和值结尾。
如果您更正元数据值,则文件将成功上传。
我在尝试通过 REST API 端点访问 BLOB 存储时收到此消息。
下面是我在调用带有Authorization标头的列表容器操作时得到的响应
<?xml version="1.0" encoding="utf-8"?>
<Error>
<Code>AuthenticationFailed</Code>
<Message>Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.
RequestId:096c6d73-f01e-0054-6816-e8eaed000000
Time:2019-03-31T23:08:43.6593937Z</Message>
<AuthenticationErrorDetail>Authentication scheme Bearer is not supported in this version.</AuthenticationErrorDetail>
</Error>
Run Code Online (Sandbox Code Playgroud)
解决方案是包含下面的标题
x-ms-version: 2017-11-09
Run Code Online (Sandbox Code Playgroud)
错误信息
服务器无法验证请求。确保授权标头的值格式正确,包括签名。
解决方案
我在应用程序中遇到了同样的问题,我通过为 key2 而不是 key1 生成共享访问签名(在 azure 门户中)解决了该问题。更改密钥修复了错误。(设置 > 共享访问签名)另请记住,连接字符串也应更新 - 如果使用的话。(设置 > 访问键)
就我而言,实际上是共享访问签名 (SAS) 过期了。通过为未来的结束日期添加一年(或更多)来更新(实际上是创建一个新的)portal.azure.com 中的共享访问签名。并且所有问题都解决了。
小智 5
检查您的网址。
共享访问令牌页面中的 Blob SAS URL 是基本容器 URL,它不是有效的 URL,并且始终会导致“服务器无法对请求进行身份验证。请确保授权标头的值格式正确,包括签名”。错误
带有令牌的基本 SAS URL 示例 https://[存储帐户].blob.core.windows.net/[容器]?[blob sas 令牌]
以下有效 URL 应该有效:
| 归档时间: |
|
| 查看次数: |
16939 次 |
| 最近记录: |