question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ListBlobsSegmentedAsync doesn't work when using a SAS url

See original GitHub issue

Hi

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:closed
  • Created 6 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
erezvani1529commented, Jun 9, 2017

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

0reactions
seanmcc-msftcommented, Apr 29, 2019

Hi everyone,

We fixed this issue in v10.0.2

Read more comments on GitHub >

github_iconTop Results From Across the Web

azure - SAS URLs not working
To fix this, try connecting the storage account first, then the blob. Share.
Read more >
cannot access to URI SAS blob storage AuthenticationFailed
It looks like you are trying to load a container via the URL in your browser. Unfortunately this is not supported by default....
Read more >
Azure Blob Storage Part 2 - Blob Gallery - Mitch Valenta
ListBlobsSegmentedAsync takes a BlobContinuationToken (null for what we want), and returns a Task<BlobResultSegment>. This gets resolved to just ...
Read more >
Access Files on Public Azure BLOB Storage using .NET Core
Users or client applications can access blobs via URLs, the Azure Storage REST API, Azure PowerShell, Azure CLI, or an Azure Storage client...
Read more >
itms-services not working with Azure blob storage SAS URL
When I'm using itms-services://?action=download-manifest&url={URL}, itms-services seem to be working. But, when I'm using ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found