Reputation: 11914
I'm having problems with the Storage emulator after upgrading my Microsoft.WindowsAzure.Storage library to version 4.0.1.
The following code:
var client = CloudStorageAccount.Parse(connectionString).CreateCloudTableClient();
var table = client.GetTableReference("TableName");
table.CreateIfNotExists();
The call to table.CreateIfNotExists()
throws a StorageException
, with detail:
Message: The remote server returned an error: (400) Bad Request.
InnerException.Response: The value for one of the HTTP headers is not in the correct format.
I am aware of the previous issue with using the 3.x client libraries with version 2.0 of the emulator (or something along those lines) and was able to work around it.
Connecting to real table service works fine, so it's something to do with the emulator.
Any ideas?
Edit: for those looking, the direct download link for the 3.2 version of the emulator is here - http://download.microsoft.com/download/0/F/1/0F162192-CDE5-413D-8DC0-37F41300B47B/WindowsAzureStorageEmulator.msi
Upvotes: 3
Views: 1205
Reputation: 10215
A 400 error in itself doesn't tell you much. Grab the exceptions RequestInformation.HttpStatusCode, RequestInformation.ExtendedErrorInformation.ErrorCode and RequestInformation.ExtendedErrorInformation.ErrorMessage, this will help you see more detail (code sample below).
Before making calls to the emulator also make sure you're aware of the various naming constraints (such as forbidden characters in partition keys, table names, etc), the data types supported (dates must be UTC, decimals aren't supported, etc) and finally the differences between what the emulator and Azure support, as there are a couple.
try
{
// do something
}
catch (StorageException ex)
{
ApplicationException aex = new ApplicationException("StorageException in SaveTransactionsToAzure()", ex);
aex.Source = "SaveTransactionsToAzure()";
aex.Data.Add("HttpStatusCode", ex.RequestInformation.HttpStatusCode);
aex.Data.Add("ErrorCode", ex.RequestInformation.ExtendedErrorInformation.ErrorCode);
aex.Data.Add("ErrorMessage", ex.RequestInformation.ExtendedErrorInformation.ErrorMessage);
throw aex;
}
Upvotes: 0
Reputation: 7951
I was stumped by the same problem for several hours. I had Azure SDK 2.3 configured against my solution and was running the old v1.7 StorageClient - worth noting is that everything worked find but I needed to upgrade the storage library to use some new features. Anyway after removing the v1.7 StorageClient and doing a NuGet on the new storage library I found I had this error. In the end I tried everything:
In the end I just reinstalled the v2.3 Azure SDK and it fixed it. No errors came up when I reinstalled, it just worked as expected.
So if in doubt do try an SDK reinstall.
Upvotes: 0
Reputation: 1378
My advice for troubleshooting emulator problems is to first make sure you have the latest version of the emulator installed. A 400 response often means you have a newer version of the client libraries and are attempting to perform an operation not yet implemented in your version of the emulator.
For more information on the latest version see here.
Jason
Upvotes: 1