AzureBlobStorage fails when enumerating Pageable<BlobContainerItem> result from GetBlobContainers with RequestFailedException, not authorized

Amber Clark (she/her/they/them) 96 Reputation points
2022-11-01T21:29:11.527+00:00

I am building an infrastructure wrapper around Azure Blob Storage for a shared component in a .Net Core 6 suite of applications, both web and desktop-based applications. I’m using version 12.14.1 of Azure.Storage.Blobs.

public BlobContainerItem[] GetContainers(string sasToken)  
{  
 blobUri = "https://spiffyaccountname.blob.core.windows.net?" + sasToken;  
  
 var client = new BlobServiceClient(blobUri);  
 var containers = client.GetBlobContainers(); // Succeeds!  
 var array = containers.array()               // Fails with Azure.RequestFailedException  
 return array;  
}  
  

Exception Details:

Azure.RequestFailedException: This request is not authorized to perform this operation using this resource type.  
RequestId:...  
Time:...  
Status: 403 (This request is not authorized to perform this operation using this resource type.)  
ErrorCode: AuthorizationResourceTypeMismatch  

I don't think it's a code issue but rather a configuration issue, as creating and deleting containers work fine, though I haven't been able to find the setting to fix it.

Azure Blob Storage
Azure Blob Storage
An Azure service that stores unstructured data in the cloud as blobs.
3,201 questions
Developer technologies | C#
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. SaiKishor-MSFT 17,336 Reputation points
    2022-11-02T22:39:17.917+00:00

    @Amber Clark (she/her/they/them) Thanks for reaching out to Microsoft Q&A. I understand that you are having issues with AzureBlobStorage fails with AuthorizationResourceTypeMismatch error.

    Resolution- Create a valid SAS token with permission to the targeted resources e.g. containers and objects. Can be achieved via portal, Storage Explorer etc. Please refer to- Create a user delegation SAS

    256572-items.png

    Please enable the above resource types as shown and see if that resolves the issue. Thank you!

    Please let us know if you have any more questions and we will be glad to assist you further. Thank you!

    Remember:

    Please accept an answer if correct. Original posters help the community find answers faster by identifying the correct answer. Here is how.

    Want a reminder to come back and check responses? Here is how to subscribe to a notification.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.