Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure exception only when deployed on server, not on localhost

I try to connect to an azure table storage and add an object. it works great on localhost, however on a server i use i get the following exception + its inner exception:

    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)

my connection string:

DefaultEndpointsProtocol=http;AccountName=nameoftable;AccountKey=accountkey...
like image 245
Guy Avatar asked Dec 07 '22 17:12

Guy


1 Answers

This is a bit of a long shot, but check the clock on the server your site is being hosted on. Part of the authentication header for all Azure storage REST calls is the current UTC. If this is too far out from what the Azure servers say is the UTC time you'll get that error.

like image 172
knightpfhor Avatar answered Dec 09 '22 13:12

knightpfhor