[英]Azure Storage - 403 Forbidden
I am getting 403 forbidden error message while connecting to azure storage from application server. 从应用程序服务器连接到azure存储时,我收到403禁用错误消息。 I am using below code snippet to check connectivity with azure storage.
我使用下面的代码片段来检查与azure存储的连接。
I am not sure it could be our firewall/proxy not allowing connectivity or related to SSL certificate (cert revocation). 我不确定它可能是我们的防火墙/代理不允许连接或与SSL证书(证书撤销)相关。 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.
Microsoft.WindowsAzure.Storage.StorageException:远程服务器返回了一个错误:(403)Forbidden。 ---> System.Net.WebException: The remote server returned an error: (403) Forbidden.
---> System.Net.WebException:远程服务器返回错误:(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
在System.Net.HttpWebRequest.GetResponse()中的Microsoft.WindowsAzure.Storage.Core.Executor.Executor.ExecuteSync [T](RESTC ommand`1 cmd,IRetryPolicy策略,OperationContext operationContext)中的c:\\ Prog ram文件(x86) \\ Jenkins \\ workspace \\ release_dotnet_master \\ Lib \\ ClassLibraryCommon \\ C ore \\ Executor \\ Executor.cs:第677行
Request Information RequestID: RequestDate:Fri, 01 Dec 2017 14:04:26 GMT StatusMessage:AccessDenied
请求信息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. 在我的情况下,我得到
403 Forbidden
因为服务器以某种方式设置为一小时。
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. 在服务器中安装
Microsoft Azure Storage Explorer
并尝试访问blob存储后,我得到了这个提示(请求时间戳太旧)。
Finally I was able to resolve this issue. 最后我能够解决这个问题。 It was with our enterprise proxy which was blocking the connection to Azure storage account.
我们的企业代理阻止了与Azure存储帐户的连接。 As I was trying to connect Azure blob storage so we had to whitelist URL *.blob.core.windows.net on the proxy.
当我尝试连接Azure blob存储时,我们不得不在代理上将 URL * .blob.core.windows.net列入白名单。
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).
除了错误的帐户密钥,如果服务器上的时间与存储服务器上的时间不同,您还可能会收到403错误(允许或允许+/- 15分钟的偏差)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.