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?
Why is KeyName NULL?
- On purpose storage account key is never made available like that.Is that causing this issue?
- I would highly doubt that. – Gaurav MantriWhat do you mean by Account Key is correct? This is not Storage Account Key, we are defining our own key here
- You need to use the storage account key for the storage account in question. In Azure Portal, go to the storage account and then access keys and then use either key1 or key2 as account key. – Gaurav Mantri