Azure Blob 存储 - sp 是必需的。不能为空

Azure Blob Storage - sp is mandatory. Cannot be empty

我在尝试使用 SAS link 将文件上传到 Azure Blob 存储时遇到错误。它是一个身份验证错误,抱怨空 sp 属性。奇怪的是 SAS Url.

中存在 Sp 元素

这不可能是权限问题,因为我可以使用相同的 SAS URL 使用 ADF 上传文件。

Url

BlobEndpoint=https://####.blob.core.windows.net/####?sp=racwdl&st=2021-12-08T01:14:01Z&se=2022-02-28T09:14:01Z&spr=https&sv=2020-08-04&sr=c&sig=####

错误详情

Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature. RequestId:ed57ec28-f01e-00a9-79d2-ebcfc2000000 Time:2021-12-08T01:22:40.1147833Z 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: sp is mandatory. Cannot be empty

Content: AuthenticationFailedServer failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature. RequestId:ed57ec28-f01e-00a9-79d2-ebcfc2000000 Time:2021-12-08T01:22:40.1147833Zsp is mandatory. Cannot be empty

Headers: x-ms-request-id: ed57ec28-f01e-00a9-79d2-ebcfc2000000 x-ms-error-code: AuthenticationFailed Content-Length: 407 Content-Type: application/xml Date: Wed, 08 Dec 2021 01:22:39 GMT Server: Microsoft-HTTPAPI/2.0

代码

Stream file = new FileStream(fileToUpload, FileMode.Open);
                var blobServiceClient1 = new BlobServiceClient(endpointString);
                var containerRef = blobServiceClient1.GetBlobContainerClient("dropoff-commissionstatements");
                var blob1 = containerRef.GetBlobClient("TDM_FINAL_102449_13092021_COMMSTMT_AR_TAL_D95337.csv");
                string file_extension = Path.GetExtension(fileToUpload);
                string filename_withExtension = Path.GetFileName(fileToUpload);
                blob1.Upload(file);

请尝试将您的连接字符串更改为类似以下内容:

BlobEndpoint=https://####.blob.core.windows.net/####; SharedAccessSignature=sp=racwdl&st=2021-12-08T01:14:01Z&se=2022-02-28T09:14:01Z&spr=https&sv=2020-08-04&sr=c&sig=####

更多详情,请看这个link:https://docs.microsoft.com/en-us/azure/storage/common/storage-configure-connection-string#create-a-connection-string-using-a-shared-access-signature