ListBlobsSegmentedAsync doesn't work when using a SAS url
See original GitHub issueHi
I’ve found a problem using SAS ‘shared access signature’ url when retrieving a blob list from a container.
I’m using WindowsAzure.Storage nuget package v8.1.4 with .net Core. But it seems to happen with previous versions as well (but I only tested those compatible with my current project configuration).
This code works.
var storageAccount = CloudStorageAccount.Parse(AzureConfig.Default.ConnectionString1);
var client = storageAccount.CreateCloudBlobClient();
var container = client.GetContainerReference("mct-123456");
var segment = await container.ListBlobsSegmentedAsync("", true, BlobListingDetails.None, null, continuationToken, null, null);
But the equivalent code using a SAS url doesnt work,
var client = new CloudBlobClient(new Uri(AzureConfig.Default.SasUrl));
var container = client.GetContainerReference("mct-123456");
var segment = await container.ListBlobsSegmentedAsync("", true, BlobListingDetails.None, null, continuationToken, null, null);
… being SasUrl a valid SAS url with full permissions. I’ve been able to create, enumerate, and delete containers using it. It also works uploading files and retrieving them when the name is known.
For the record, SaSUrl it is something similar to this (that is a fake)
https://dummy.blob.core.windows.net/?sv=2016-05-31&ss=b&srt=sco&sp=rwdlac&se=2090-06-08T05:32:45Z&st=2017-06-06T21:32:45Z&spr=https&sig=NNnHStoNwGoWxmI9n4fc4JYRFqgLQE5wUOcsiZUR6IY%3D
Using Fiddler I’ve verified that the REST request is done and answered, therefore the file list has been properly downloaded. It seems a handling error, as the “ParseQueryAndVerify” method, where the error actually happens, seems to suggest.
Here are the exception details:
Cannot provide credentials as part of the address and as constructor parameter. Either pass in the address or use a different constructor.
at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.<ExecuteAsyncInternal>d__4`1.MoveNext() in C:\Program Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\WindowsRuntime\Core\Executor\Executor.cs:line 315
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.WindowsAzure.Storage.Blob.CloudBlobContainer.<>c__DisplayClass61_0.<<ListBlobsSegmentedAsync>b__0>d.MoveNext() in C:\Program Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\WindowsRuntime\Blob\CloudBlobContainer.cs:line 429
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at Project1.AzureImpl.<GetAllFiles>d__10.MoveNext() in d:\project1\AzureImpl.cs:line 122
And the internal exception
Cannot provide credentials as part of the address and as constructor parameter. Either pass in the address or use a different constructor.
at Microsoft.WindowsAzure.Storage.Blob.CloudBlob.ParseQueryAndVerify(StorageUri address, StorageCredentials credentials) in C:\Program Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\Common\Blob\CloudBlob.Common.cs:line 481
at Microsoft.WindowsAzure.Storage.Blob.CloudBlob..ctor(BlobAttributes attributes, CloudBlobClient serviceClient) in C:\Program Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\Common\Blob\CloudBlob.Common.cs:line 120
at Microsoft.WindowsAzure.Storage.Blob.CloudBlobContainer.SelectListBlobItem(IListBlobEntry protocolItem) in C:\Program Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\WindowsRuntime\Blob\CloudBlobContainer.cs:line 1260
at System.Linq.Enumerable.SelectEnumerableIterator`2.MoveNext()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at Microsoft.WindowsAzure.Storage.Blob.CloudBlobContainer.<>c__DisplayClass106_1.<ListBlobsImpl>b__3() in C:\Program Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\WindowsRuntime\Blob\CloudBlobContainer.cs:line 1327
at System.Threading.Tasks.Task`1.InnerInvoke()
at System.Threading.Tasks.Task.Execute()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.<ExecuteAsyncInternal>d__4`1.MoveNext() in C:\Program Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\WindowsRuntime\Core\Executor\Executor.cs:line 230
Issue Analytics
- State:
- Created 6 years ago
- Comments:8 (3 by maintainers)
Top GitHub Comments
Hi @marcoregueira,
Thanks for reporting this issue. This is a bug and we have a fix for it (out with next release). As a workaround try providing the credentials through creating a StorageCredentials instance such as below:
StorageCredentials credentials = new StorageCredentials(/Your SAS Token/); CloudBlobClient client = new CloudBlobClient(/* Your Base Uri */, credentials);
Thanks, Elham
Hi everyone,
We fixed this issue in v10.0.2