Vikram
Vikram

Reputation: 6877

Azure CloudBlobContainer.CreateIfNotExists() throws Forbidden (403) on Local Development

I've started getting 403 Error on blobContainer.createIfNotExists. Following is the source code.

 CloudStorageAccount storageAccount = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("StorageConnectionString"));
        string blobContainerName =string.IsNullOrEmpty(_sessionContext.DomainName) ? "localdevblob": _sessionContext.DomainName.ToLower();
        CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
        CloudBlobContainer container = blobClient.GetContainerReference(blobContainerName);
        container.CreateIfNotExists();

Things verified:

Anticipating that upgrading the library might fix the issue:

The exception screenshot is below:

enter image description here

UPDATE

Apparently, i just downloaded the sample from https://github.com/Azure-Samples/storage-blob-dotnet-getting-started.git and that works too. and when i compared the cloudBlobClient object in my project and the sample project i found that for some strange reason I found that blobClient (in my project) is missing "AuthenticationHandler" and the "Key" which would be causing the issue. But these 2 values are present in the sample project.

enter image description here

Upvotes: 1

Views: 4389

Answers (1)

Fei Han
Fei Han

Reputation: 27793

getting 403 Error on blobContainer.createIfNotExists

I created a sample to reproduce the issue on my side, the code works fine with installing WindowsAzure.Storage sdk v8.1.0 to v8.1.4 and v8.4.0.

CloudStorageAccount storageAccount = CloudStorageAccount.Parse("UseDevelopmentStorage=true");

CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();

CloudBlobContainer container = blobClient.GetContainerReference("mycontainer");

container.CreateIfNotExists();

And I also test the code with WindowsAzure.Storage v7.0.0, it works too.

Besides, some community members report that the WindowsAzure.Storage sdk returns 403 error when do storage operations if ApplicationInsights is installed in project, this SO thread discussed it.

Upvotes: 3

Related Questions