Hi,
I have been given a SASUri link to develop a console app to upload/download files from Azure blob. I can attach the SASUri link from Azure Storage Explorer and see the files.
SASUri - https://STORAGEACCOUNT.blob.core.windows.net/testcontainer?sv=2020-04-08&si=test-read&sr=c&sig=SIGNATURE
When I use the code below to call the link, I received the error. Does anyone have a sample to upload/download files from a given SASUri link?
BlobClient blobClient = new BlobClient(new Uri("https://STORAGEACCOUNT.blob.core.windows.net/testcontainer?sv=2020-04-08&si=test-read&sr=c&sig=SIGNATURE"));
Azure.Response<BlobDownloadInfo> response = blobClient.Download();
Azure.RequestFailedException
HResult=0x80131500
Message=Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.
RequestId:c08759e2-f01e-006e-6deb-1cb6b6000000
Time:2021-03-19T18:14:19.6133856Z
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 did not match. String to sign used was
/blob/STORAGEACCOUNT/$root
test-read
2020-04-08
c
Headers:
Server: Microsoft-HTTPAPI/2.0
x-ms-request-id: c08759e2-f01e-006e-6deb-1cb6b6000000
x-ms-error-code: AuthenticationFailed
Date: Fri, 19 Mar 2021 18:14:19 GMT
Content-Length: 481
Content-Type: application/xml
Source=Azure.Storage.Blobs
StackTrace:
at Azure.Storage.Blobs.BlobRestClient.Blob.DownloadAsync_CreateResponse(ClientDiagnostics clientDiagnostics, Response response)
at Azure.Storage.Blobs.BlobRestClient.Blob.<DownloadAsync>d__0.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
at System.Threading.Tasks.ValueTask1.get_Result() at System.Runtime.CompilerServices.ConfiguredValueTaskAwaitable
1.ConfiguredValueTaskAwaiter.GetResult()
at Azure.Storage.Blobs.Specialized.BlobBaseClient.<StartDownloadAsync>d__61.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable1.ConfiguredTaskAwaiter.GetResult() at Azure.Storage.Blobs.Specialized.BlobBaseClient.<DownloadInternal>d__60.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter
1.GetResult()
at Azure.Core.Pipeline.TaskExtensions.EnsureCompletedT
at Azure.Storage.Blobs.Specialized.BlobBaseClient.Download(HttpRange range, BlobRequestConditions conditions, Boolean rangeGetContentHash, CancellationToken cancellationToken)
at Azure.Storage.Blobs.Specialized.BlobBaseClient.Download(CancellationToken cancellationToken)
at Azure.Storage.Blobs.Specialized.BlobBaseClient.Download()
at AzureApp.Program.<Main>g__GetAccountContainerAndBlobNameFromUrl|0_0() in C:\Brian\AzureApp\Program.cs:line 25
at AzureApp.Program.Main(String[] args) in C:\Brian\AzureApp\Program.cs:line 18