Reputation: 1258
Question: What am I missing to access azure development table storage?
Note: I can access my azure CLOUD storage (using different code of course), but I am failing when trying to access the development storage.
I'm using:
Microsoft Azure Storage Emulator v4.0 <- changing to v4.2 fixed issue
var cloudStorageAccount = CloudStorageAccount.DevelopmentStorageAccount;
var tableClient = cloudStorageAccount.CreateCloudTableClient();
var table = tableClient.GetTableReference("MYTEMPTABLE");
var iscreated = table.CreateIfNotExists();
The last statement gives this exception
The remote server returned an error: (400) Bad Request.
The value for one of the HTTP headers is not in the correct format.
RequestId:f0b37575-30f4-45c1-bec3-2620c3c605e7
Time:2015-11-04T16:12:37.4719620Z
StackTrace
at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.ExecuteSync[T](RESTCommand`1 cmd, IRetryPolicy policy, OperationContext operationContext) in c:\Program Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\ClassLibraryCommon\Core\Executor\Executor.cs:line 816
at Microsoft.WindowsAzure.Storage.Table.TableOperation.Execute(CloudTableClient client, CloudTable table, TableRequestOptions requestOptions, OperationContext operationContext) in c:\Program Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\ClassLibraryCommon\Table\TableOperation.cs:line 41
at Microsoft.WindowsAzure.Storage.Table.CloudTable.Exists(Boolean primaryOnly, TableRequestOptions requestOptions, OperationContext operationContext) in c:\Program Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\ClassLibraryCommon\Table\CloudTable.cs:line 1605
at Microsoft.WindowsAzure.Storage.Table.CloudTable.CreateIfNotExists(TableRequestOptions requestOptions, OperationContext operationContext) in c:\Program Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\ClassLibraryCommon\Table\CloudTable.cs:line 1024
at USPS.Cloud.Integration.AspProviders.UspsReturnsStorageBase.CreateStorageAccountFromConnectionString() in ... <my local code call stack>
FYI: In searching MSDN, StackOverflow, etc, I've found 3 ways to get a CloudStorageAccount object to access the storage emulator. The first 2 give the error above. The 3rd gives a 403 error.
CloudStorageAccount = CloudStorageAccount.DevelopmentStorageAccount;
CloudStorageAccount = CloudStorageAccount.Parse("UseDevelopmentStorage=true");
var devAccountName = "devstoreaccount1";
var devAccountKey = "Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==";
var devCredentials = new StorageCredentials(devAccountName, devAccountKey);
var cloudStorageAccount = new CloudStorageAccount(devCredentials, true);
UPDATE
As stated in the answer, I did not have the correct emulator version. Dev storage connections 1 & 2 above work. Following the link in the answer by @Emily Gerner - MSFT led me to this for a working option 3.
var devConnectionString = "DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://127.0.0.1:10000/devstoreaccount1;TableEndpoint=http://127.0.0.1:10002/devstoreaccount1;QueueEndpoint=http://127.0.0.1:10001/devstoreaccount1;";
CloudStorageAccount = CloudStorageAccount.Parse(devConnectionString);
Upvotes: 3
Views: 4616
Reputation: 1
I too was getting the 400 errors. In my case I had trouble starting the Azure Storage Emulator. The reason was some other process was listening on that port. So I went and changed the port numbers in AzureStorageEmulator.exe. You can find this config file @ C:\Program Files (x86)\Microsoft SDKs\Azure\Storage Emulator. Or whereever you installed the emulator. After that the emulator started. But this 400 still didn't go away. So I used this setting in the config file. "UseDevelopmentStorage=true;DevelopmentStorageProxyUri=http://ipv4.fiddler" [Azure October 2012 SDK broke UseDevelopmentStorage=true. Looking at fiddler I realized that the request is being directed to port number 10000. I found no way to change it. So I killed whatever process was using that port. Reset my config files back to original state. Now the blob, queue, and table are using the original port number. The Azure storage emulator was restarted. Now magically the 400 error disappeared.
Upvotes: 0
Reputation: 1717
Looks AzureStorage NugetPackage > 6.0.0 works with Azure SDK 2.8 (Storage Emulator 4.8)
Upvotes: 0
Reputation: 2457
The third doesn't work as you're not setting the emulator endpoints and it's sending to the service account devstoreaccount1 rather than to your local emulator. Try using TableEndpoint=http://127.0.0.1:10002/devstoreaccount1 for example. The Azure emulator docs have more details if necessary.
If you see the README section on the Emulator you'll see the latest storage lib versions require min emulator version 4.2. This should also provide a download link. You get 400 Bad Request as the library version you're using uses a service version the old emulators have no way of knowing about.
Upvotes: 5