Register
Sunday, February 05, 2012
 
 DBAs And ProgrammersBlog
  
News! Minimize
   
 
 Print   
 
Misc Blog Stuff Minimize
   
 
 Print   
 
The Reluctant DBA Minimize
 
 
 
 Print   
 
Reluctant DBA Minimize
   
 
  
 
Reluctant DBA Minimize
   
 
  
 
The Reluctant DBA Minimize
 
May23

Written by:CarpDeus
5/23/2009 9:33 PM 

I've been working more on the demos for VSLive Las Vegas and, one thing I wanted was a good, simple class for interfacing with Azure Table Storage (ATS) and, ultimately, all of the Azure tools. Mike Amundsen had a good start with a tool he built but it didn't do some of the things I was looking for so I started modifying it. Many of the changes I made were to make it easier for teaching with but one of the major changes I wanted to make was to be able to handle bulk commands.

"How hard can this be", I asked myself. If you look at the format that ATS wants, you have to provide the PartitionKey and RowKey in the XML block of data. So, I figured, just pull out those two values and you can easily do bulk POST/PUT/MERGE/DELETE.  True, ATS uses name spaces but I'm already working with those to pull data out of the returned XML when I get a list of tables. So, I took the set of data I had used with Mike's console app and formatted it to XML. Copied and pasted it into an XML block that had the appropriate schemas defined and got something like this:


http://finseldemos.table.core.windows.net/" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns="http://www.w3.org/2005/Atom">

  website
  04AF565A-157E-4679-BE90-C15AED3D01DF
  Happy Blues
  HappyBlues.ReluctantDBA.com
  W1


  CalendarEntry
  1
  New Years Day
 
   2008-01-01T00:00:00"
 

 
  W1

I got this by creating an XML document in VS2005 and pasting in my XML data, never noticing the subtle error. At first I thought the problem was within my code because this:

XmlDocument xdoc = new XmlDocument();
xdoc.LoadXml(docData );
//Instantiate an XmlNamespaceManager object.
System.Xml.XmlNamespaceManager xmlnsManager = new System.Xml.XmlNamespaceManager(xdoc.NameTable);

//Add the namespaces used in books.xml to the XmlNamespaceManager.
xmlnsManager.AddNamespace("d", "http://schemas.microsoft.com/ado/2007/08/dataservices");
xmlnsManager.AddNamespace("m", "http://schemas.microsoft.com/ado/2007/08/dataservices/metadata");
XmlNodeList nodes = xdoc.SelectNodes("//m:properties", xmlnsManager);

created this:

http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">http://schemas.microsoft.com/ado/2007/08/dataservices">websitehttp://schemas.microsoft.com/ado/2007/08/dataservices">04AF565A-157E-4679-BE90-C15AED3D01DFhttp://schemas.microsoft.com/ado/2007/08/dataservices">Happy Blueshttp://schemas.microsoft.com/ado/2007/08/dataservices">HappyBlues.ReluctantDBA.comhttp://schemas.microsoft.com/ado/2007/08/dataservices">W1

Which, as you can see, added the namespaces to each element. And it was throwing errors when presented to ATS. So, I stripped out the namespaces using string.Replace and still got the error. But only on the CalendarEntry partition keys. The website was fine. So I dug deeper and found the problem was that every date had an extraneous double quote after it:


   2008-01-01T00:00:00"
 

I have no idea why. But I fixed it and the tool handles bulk commands. Except that pasting the entire set of calendar data takes too long and causes it to time out, so tomorrow I'll create a Worker Role to process bulk uploads. And, probably early next week,  I'll be releasing code, not just snippets.

That's enough for today. But check out the on-line version at http://cloudquotes.cloudapp.net/AzureLookup.aspx

Tags:

Your name:
Your email:
(Optional) Email used only to show Gravatar.
Your website:
Title:
Comment:
Security Code
Enter the code shown above in the box below
Add Comment  Cancel 
 
 
  
 
Privacy Statement | Terms Of Use Copyright 2001-2008 by ReluctantDBA.com