...and everything in between RSS 2.0
# Tuesday, January 25, 2011

I am finding that the development storage emulator has a few “undocumented features”. A few days ago, I was happily working through the Windows Azure Training Kit and things were going well. Today I was putting together a PoC using pieces learnt from the labs. I kept hitting a problem when trying to insert an entity into the newly created table storage (running on the local Storage Emulator). I was getting the generic error message when querying the collection:

“one of the request inputs is not valid”

var match = (from c in this.context.Clients
              where c.Name == name
              select c).FirstOrDefault();

 

Some things I tried that didn’t help:

  • Restarting the Storage Emulator a few times.
  • Restarting the machine (always worth a shot!)
  • Deleting the entries in the TableContainer and TableRow tables in the development storage DB.
  • Recreating the development storage DB using DSINIT /forceCreate.
  • Running around the office naked.

After hunting around for quite some time (including running the lab code again and getting them same result) I tracked it down to the table storage schema not being created after issuing

CloudTableClient.CreateTablesFromModel(
   typeof(MyDataServiceContext),
   storageAccount.TableEndpoint.AbsoluteUri,
   storageAccount.Credentials);

Note: This worked happily when I was working through the labs a few days ago. Neither my code nor the lab code was working now. Annoyed

Looking at the underlying DB (using SQLEXPRESS on my VM) I found no schema populated

underlying_table_storage

After some frustrating searching, I came across this post that suggested an ugly work around > azure-table-storage-what-a-pain-in-the-ass. It suggests that on the local storage emulator you need to “convince” the table service provider that you know what you are doing by inserting some dummy entities. This only appears to be needed when you have no data in your tables. So I added the following code in my data source constructor so it gets called by my service before performing any CRUD operations. 

// [WORK AROUND] See http://deeperdesign.wordpress.com/2010/03/10/azure-table-storage-what-a-pain-in-the-ass/
//  Generate some inserts to populate empty table
var client = new Client("dummy", "dummy");
this.context.AddObject("Clients", client);
this.context.SaveChanges();
this.context.DeleteObject(client);
this.context.SaveChanges();
 
var post = new Post("dummy", "dummy");
this.context.AddObject("Posts", post);
this.context.SaveChanges();
this.context.DeleteObject(post);
this.context.SaveChanges();
 

Ugly but it jumps the hurdle and allows me to get back to building out the rest of the solution. Just remember to comment it back out after you verify the schema xml has been populated successfully and your CRUD operations are going through.

Tuesday, January 25, 2011 1:53:33 PM (AUS Eastern Daylight Time, UTC+11:00)  #    - Trackback
Windows Azure
Navigation
Archive
<January 2011>
SunMonTueWedThuFriSat
2627282930311
2345678
9101112131415
16171819202122
23242526272829
303112345
Blogroll
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2014
Breeze
Sign In
Statistics
Total Posts: 64
This Year: 0
This Month: 0
This Week: 0
Comments: 182
Themes
Pick a theme:
All Content © 2014, Breeze
DasBlog theme 'Business' created by Christoph De Baene (delarou)