Search code examples
c#.netazure-storageazure-blob-storage

Azure Storage - 403 Forbidden


I am getting 403 forbidden error message while connecting to azure storage from application server. I am using below code snippet to check connectivity with azure storage.

I am not sure it could be our firewall/proxy not allowing connectivity or related to SSL certificate (cert revocation). I am checking with our network team on this; any suggestion would be helpful.

  string storageConnString = "DefaultEndpointsProtocol=https;AccountName=azstoragel692;AccountKey=asdfas234234sdfsdf234234;EndpointSuffix=core.windows.net";   
        var storageAccount = CloudStorageAccount.Parse(storageConnString);
        var blobStorage = storageAccount.CreateCloudBlobClient();
        CloudBlobContainer container = blobStorage.GetContainerReference("myContainer");
        var blobsCount = container.ListBlobs().Count();
        Console.WriteLine(blobsCount);

Exception:

Microsoft.WindowsAzure.Storage.StorageException: The remote server returned an e rror: (403) Forbidden. ---> System.Net.WebException: The remote server returned an error: (403) Forbidden.

at System.Net.HttpWebRequest.GetResponse() at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.ExecuteSync[T](RESTC ommand`1 cmd, IRetryPolicy policy, OperationContext operationContext) in c:\Prog ram Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\ClassLibraryCommon\C ore\Executor\Executor.cs:line 677

Request Information RequestID: RequestDate:Fri, 01 Dec 2017 14:04:26 GMT StatusMessage:AccessDenied


Solution

  • Finally I was able to resolve this issue. It was with our enterprise proxy which was blocking the connection to Azure storage account. As I was trying to connect Azure blob storage so we had to whitelist URL *.blob.core.windows.net on the proxy.