question

amsDeveloper-1720 avatar image
0 Votes"
amsDeveloper-1720 asked AndrSantos-1191 answered

Azure Storage : Unable to access Container blobs with defined Credentials

We are setting a Key for the Storage Account and then using to access the contents as below;

 var storageCredentials = new StorageCredentials(mediaStorageAccountName, base64EncodedKey);
 var storageAccount = new CloudStorageAccount(storageCredentials, true);
 var connString = storageAccount.ToString(true);

Then, using the same "storageAccount" to create the Blob Client;

 CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();

And to get the Container;

 var container = blobClient.GetContainerReference(ContainerName);

"storageAccount" Credential properties are "IsSAS" FALSE, "IsSharedKey" TRUE, "IsToken" FALSE and "KeyName" is NULL.

But, when Blob is being accessed with OpenReadAsync, its failing with following exception;

The remote server returned an error: (403) Forbidden.,The remote server returned an error: (403) Forbidden. Line number: Microsoft.WindowsAzure.Storage Trace: at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.EndExecuteAsync[T](IAsyncResult result) at Microsoft.WindowsAzure.Storage.Blob.CloudBlob.EndExists(IAsyncResult asyncResult) at Microsoft.WindowsAzure.Storage.Core.Util.AsyncExtensions.<>c_DisplayClass2`1.b_0(IAsyncResult ar)

It is basically getting all the references to Container/Blobs etc correctly (gives correct name), but when its tried to read/download/upload those, it fails.

Also, instead of using the "storageAccount" reference directly, even if it is secured with following, it gives same exception;

 CloudStorageAccount storageAccount = new CloudStorageAccount(
    new Microsoft.WindowsAzure.Storage.Auth.StorageCredentials(storageAccountName, base64EncodedKey), true);

What is wrong here and how to fix this? Why is KeyName NULL? Is that causing this issue?







azure-storage-accountsazure-blob-storage
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

deherman-MSFT avatar image
0 Votes"
deherman-MSFT answered amsDeveloper-1720 commented

@amsDeveloper-1720 Apologies for the delayed response here and any inconvenience this has caused. Often times 403 is seen when authorizing with a shared key because "All authorized requests must include the Coordinated Universal Time (UTC) timestamp for the request." Information about this can be found in Authorize with Shared Key




Please don’t forget to "Accept the answer” and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.


· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

The same code (without time co-ordinated UTC time stamp) works for another Storage Account and fails for this Storage Account, which is also causing issue as specified here https://docs.microsoft.com/en-us/answers/questions/40660/azure-storage-account-blob-service-sas-connectivit.html
So, somehow both issue look related to me.

0 Votes 0 ·
Sumarigo-MSFT avatar image
0 Votes"
Sumarigo-MSFT answered amsDeveloper-1720 commented

@amsDeveloper-1720 Just checking in to see if the above answer helped. If this answers your query, please don’t forget to "Accept the answer" and Up-Vote for the same, which might be beneficial to other community members reading this thread. And, if you have any further query do let us know.


Adding some information to @dehermanYou can specify the timestamp either in the x-ms-date header, or in the standard HTTP/HTTPS Date header. The storage services ensure that a request is no older than 15 minutes by the time it reaches the service. This guards against certain security attacks, including replay attacks. When this check fails, the server returns response code 403 (Forbidden). Check your Server data-time in this scenario


· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

The answer may be correct, but the same code (without time limit/header) works for another Storage Account and fails for this Storage Account, which is also causing issue as specified here https://docs.microsoft.com/en-us/answers/questions/40660/azure-storage-account-blob-service-sas-connectivit.html
So, somehow both issue look related to me.

0 Votes 0 ·

@amsDeveloper-1720 Just checking in to see if the above answer helped. If this answers your query, please don’t forget to "Accept the answer" and Up-Vote for the same, which might be beneficial to other community members reading this thread. And, if you have any further query do let us know.


If you are still facing any issue, please let me know I will love to work closer on this issue. could you send an email to AzCommunity[at]Microsoft[dot]com referencing this thread and subscription ID. Please mention "ATTN subm" in the subject field. Thank you for your cooperation on this matter and look forward to your reply.


0 Votes 0 ·

Thank you! I have mailed the details.

0 Votes 0 ·
ThaynaJhanaABEspndola-9666 avatar image
0 Votes"
ThaynaJhanaABEspndola-9666 answered ThaynaJhanaABEspndola-9666 published

Did you find a solution to the problem?

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

AndrSantos-1191 avatar image
0 Votes"
AndrSantos-1191 answered

After rotate key, this issue is solved. This problem is bizarre

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.