I am using libraries Microsoft.Azure.Storage.Blob
11.2.3.0 and Microsoft.Azure.Storage.Common
11.2.3.0 to connect to an Azure BlobStorage from a .NET Core 3.1 application.
When I started working on this, I had been given connection strings that gave me full access to the BlobStorage (or rather, the entire cloud storage account). Based upon those, I chose to write my connection code "defensively", making use of Exists()
and CreateIfNotExists()
from the CloudBlobContainer
class to ensure the application would not fail when a container was not yet existing.
Now, I'm connecting a BlobStorage container using a SAS. While I can freely retrieve and upload blobs within the container like this, unfortunately, it seems that I am not allowed to do anything on the container level. Not only CreateIfNotExists
, but even the mere querying of existence by Exists()
throws a StorageException
saying
This request is not authorized to perform this operation.
The documentation does not mention the exception.
Is there any way to check preemptively whether I am allowed to check the container's existence?
I have tried looking into the container permissions retrieved from GetPermissions
, but that will throw an exception, as well.
The only other alternative I can see is to check for container existence within a try
-catch
-block and assume existence if an exception is thrown ...