【发布时间】:2021-11-10 23:34:44
【问题描述】:
您好,我正在尝试使用 SAS 令牌访问 Azure Blob 以从 Blob 中获取数据,这是我尝试过的。
我对此很陌生,所以不知道它应该如何工作
这是我迄今为止尝试过的。
您能否建议这是否是从 Blob 获取数据的正确方法以及如何解决我遇到的此错误
错误是
这是目前写的代码
namespace BlobQuickstartV12
{
class Program
{
static async Task Main()
{
const string sasToken = "sasToken";
var blobUri = new System.Uri("https://xx.blob.xx.xx.net/xxxx?sp=ral&st=2021-07-28T22:29:14Z&se=2021-08-26T06:29:14Z&spr=https&sv=2020-08-04&sr=c&sig=ZQ%2Bl5yZ2JpEb7TwnWGBNz9hSjGTZr3ZarSPaQ1ssz48%3D");
var blobUriBuilder = new System.UriBuilder(blobUri)
{
Query = sasToken
};
var authorizedBlobUri = blobUriBuilder.Uri;
var blobClient = new Azure.Storage.Blobs.BlobClient(authorizedBlobUri);
var getBlobResponse = await blobClient.DownloadContentAsync(); //ERROR HERE
Console.WriteLine("Read blob successfully", getBlobResponse.Value);
}
}
}
错误
Azure.RequestFailedException: 'Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.
RequestId:cbde76c1-b01e-008e-657c-aa7496000999
Time:2021-09-15T21:55:49.0166554Z
Status: 403 (Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.)
ErrorCode: AuthenticationFailed
Additional Information:
AuthenticationErrorDetail: Signature not valid in the specified time frame: Start [Wed, 28 Jul 2021 22:29:14 GMT] - Expiry [Thu, 26 Aug 2021 06:29:14 GMT] - Current [Wed, 15 Sep 2021 21:55:49 GMT]
Content:
<?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:cbde76c1-b01e-008e-657c-aa7496000000
Time:2021-09-15T21:55:49.0166554Z</Message><AuthenticationErrorDetail>Signature not valid in the specified time frame: Start [Wed, 28 Jul 2021 22:29:14 GMT] - Expiry [Thu, 26 Aug 2021 06:29:14 GMT] - Current [Wed, 15 Sep 2021 21:55:49 GMT]</AuthenticationErrorDetail></Error>
Headers:
Server: Microsoft-HTTPAPI/2.0
x-ms-request-id: cbde76c1-b01e-008e-657c-aa7496000000
x-ms-error-code: AuthenticationFailed
Date: Wed, 15 Sep 2021 21:55:48 GMT
Content-Length: 544
Content-Type: application/xml
'
有什么建议
谢谢 回复
【问题讨论】:
标签: c# .net azure azure-blob-storage