仅在部署在服务器上而不是在localhost上部署Azure异常时

时间:2011-12-16 16:04:35

标签: azure azure-table-storage

我尝试连接到azure表存储并添加一个对象。它在localhost上工作得很好,但是在我使用的服务器上我得到以下异常+它的内部异常:

    Exception of type 'Microsoft.WindowsAzure.StorageClient.StorageClientException' was thrown.
System.Data.Services.Client.DataServiceQueryException: An error occurred while processing this request. 
---> System.Data.Services.Client.DataServiceClientException: 
     <?xml version="1.0" encoding="utf-8" standalone="yes"?>
     <error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
     <code>AuthenticationFailed</code>
     <message xml:lang="en-US">Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature. RequestId:17..127 Time:2011-12-16T15:47:50.7505473Z</message>
     </error>
     at System.Data.Services.Client.BaseAsyncResult.EndExecute[T](Object source, String method, IAsyncResult asyncResult)
     at System.Data.Services.Client.QueryResult.EndExecute[TElement](Object source, IAsyncResult asyncResult)
     --- End of inner exception stack trace ---
     at Microsoft.WindowsAzure.StorageClient.Tasks.Task`1.get_Result()
     at Microsoft.WindowsAzure.StorageClient.CloudTableClient.GetResultOrDefault[T](Task`1 task, T& result)

我的连接字符串:

DefaultEndpointsProtocol=http;AccountName=nameoftable;AccountKey=accountkey...

2 个答案:

答案 0 :(得分:15)

这是一个很长的镜头,但检查您的网站托管服务器上的时钟。所有Azure存储REST调用的authentication header部分是当前的UTC。如果这与Azure服务器所说的是UTC时间太远,那么您将收到该错误。

答案 1 :(得分:0)

您必须在角色的设置中更改数据连接字符串。我非常确定您错误存储帐户密钥,或者您保留默认连接字符串“UseDevelopmentStorage = true”

没有适用于Azure存储的防火墙规则,只有访问帐户。如果您尚未创建存储,则必须创建存储。我建议您在托管服务所在的同一数据中心内创建存储,以避免流量费用。然后只使用门户中提供的存储帐户和密钥。

enter image description here

典型的真实存储帐户连接字符串如下所示:

DefaultEndpointsProtocol = https和帐户名= YOUR_ACCOUNT_NAME; AccountKey = YOUR_ACCOUNT_KEY_BE_IT_PRIMARY_OR_SECONDARY ==