简体   繁体   中英

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

I know this is the answer for your case but it may be the answer for someone else.

In my case, I was getting 403 Forbidden because the server was somehow set to an hour before.

This was followed by an issue with the data center. I can't be sure if this was the cause but the fact is that after I synced the time correctly, it started working just fine.

I got this tip (request timestamp too old) after installing Microsoft Azure Storage Explorer in the server and trying to access the blob storage.

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.

Please check the clock on the servers in question. Apart from the incorrect account key, you can also get 403 error if the time on the server is not in sync with the time on storage servers (Give or take +/- 15 minutes deviation is allowed).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM