{"id":712,"date":"2010-12-14T23:26:19","date_gmt":"2010-12-14T22:26:19","guid":{"rendered":"http:\/\/www.gennard.net\/blog\/?p=712"},"modified":"2010-12-14T23:26:19","modified_gmt":"2010-12-14T22:26:19","slug":"azurekit-and-cobol","status":"publish","type":"post","link":"http:\/\/www.gennard.net\/blog\/2010\/12\/azurekit-and-cobol\/","title":{"rendered":"AzureKit and COBOL"},"content":{"rendered":"<p>AzureKit is a nice piece of source code released on CodePlex by Mark Rendle.   The AzureKit makes life much easier for creating, searching, deleting elements in your Azure&#8217;s Table Storage.<\/p>\n<p>My idea was that if the AzureKit was easy enough to use, then it could give us a nice way of accessing Azure&#8217;s table storage without to hosted in Azure itself.<\/p>\n<p>Given, this idea I recently spend a bit of time exploring the APIs and how they could be used from COBOL and to be honest it was a pleasure to use, so thank you Mark for the good work.<\/p>\n<p>For anyone not familar with Azure Table Storage, it is a structured storage that uses tables.. sounds obvious.  It does not have a SQL interface, so it is marked as a NoSQL storage mechanism.<\/p>\n<p>The normal Azure Table Storage APIs are fine but reasonably complicated&#8230; perhaps too complicated for most people to use.<\/p>\n<p>The APIs Mark has put together really does make life easier.<\/p>\n<p>The AzureKit provides you with an IDictionary, IEnumerable and IQueryable style interface which for anyone familar with .Net this API style will feel very natural to them, so I think it gives you a nice programming model.<\/p>\n<p>This combined with Visual COBOL&#8217;s support for doing &#8216;perform thru&#8217; on IQueryable objects make its easy to use..   Anyway enough talking time for some code&#8230;<\/p>\n<p><code lang=\"cobol\" width=\"800\" lines=\"-1\" nowrap=\"0><br \/>\n      program-id. Program1 as \"AzureKitExample.Program1\".<\/p>\n<p>       data division.<br \/>\n       working-storage section.<br \/>\n       01 movieTable    type AzureKit.Table.<br \/>\n       01 movie         type IDictionary[string, object].<br \/>\n       01 movieQuery    type IEnumerable[<br \/>\n                                   type IDictionary[string, object]].<br \/>\n       01 movieIQuery   type System.Linq.IQueryable[<br \/>\n                                   type IDictionary[string, object]].<\/p>\n<p>       procedure division.<br \/>\n           set type Azure::Account to \"mystorageaccount\"<br \/>\n           set type Azure::SharedKey to \"myverylargesharedkey..........\"<br \/>\n           set movieTable to new type AzureKit.Table(\"Movie\",<br \/>\n                            type AzureKit.IfTableDoesNotExist::CreateIt)<\/p>\n<p>           *> Delete ALL<br \/>\n           perform varying movie thru movieTable::GetAllRows()<br \/>\n               invoke movieTable::Delete(movie)<br \/>\n           end-perform<\/p>\n<p>           *> All two items<br \/>\n           set movie to type AzureKit.Table::NewRow(<br \/>\n                                   \"Jaws: The Revenge\",<br \/>\n                                   type Guid::NewGuid()::ToString())<br \/>\n           set movie::Item(\"Year\") to 1987<br \/>\n           set movie::Item(\"Director\") to \"Joseph Sargent\"<br \/>\n           set movie::Item(\"Rating\") to \"Worst Movie Ever!\"<br \/>\n           invoke movieTable::InsertRow(movie)<\/p>\n<p>           set movie to type AzureKit.Table::NewRow(<br \/>\n                                   \"Empire Strikes Back\",<br \/>\n                                   type Guid::NewGuid()::ToString())<br \/>\n           set movie::Item(\"Year\") to 1982<br \/>\n           set movie::Item(\"Director\") to \"George Lucas\"<br \/>\n           set movie::Item(\"Rating\") to \"Best Movie Ever!\"<br \/>\n           invoke movieTable::InsertRow(movie)<\/p>\n<p>           *> query<br \/>\n           set movieQuery to movieTable::Query(<br \/>\n                                 \"PartitionKey eq 'Jaws: The Revenge'\")<\/p>\n<p>           set movieIQuery to type System.Linq.Queryable::AsQueryable[<br \/>\n                                 type IDictionary[<br \/>\n                                     string, object]](movieQuery)<\/p>\n<p>           set movie to type System.Linq.Queryable::FirstOrDefault[<br \/>\n                                 type IDictionary[<br \/>\n                                     string, object]](movieIQuery)<\/p>\n<p>           display movie::Item(\"PartitionKey\") \" -> \"<br \/>\n                                   movie::Item(\"Director\") \" -> \"<br \/>\n                                   movie::Item(\"RowKey\")      <\/p>\n<p>           *> show the results<br \/>\n           perform varying movie thru movieQuery<br \/>\n                  display movie::Item(\"PartitionKey\") \" -> \"<br \/>\n                                  movie::Item(\"Director\") \" -> \"<br \/>\n                                  movie::Item(\"RowKey\")<br \/>\n           end-perform<\/p>\n<p>           goback.<\/p>\n<p>       end program Program1.<\/p>\n<p><\/code><\/p>\n<p>That&#8217;s pretty easy&#8230; now what shall I do with the APIs&#8230; answers on the comment strip!<\/p>\n<p>http:\/\/blog.markrendle.net\/<br \/>\nhttp:\/\/azurekit.codeplex.com\/<br \/>\nhttp:\/\/msdn.microsoft.com\/en-us\/library\/dd179423.aspx<\/p>\n","protected":false},"excerpt":{"rendered":"<p>AzureKit is a nice piece of source code released on CodePlex by Mark Rendle. The AzureKit makes life much easier for creating, searching, deleting elements in your Azure&#8217;s Table Storage. My idea was that if the AzureKit was easy enough &hellip; <a href=\"http:\/\/www.gennard.net\/blog\/2010\/12\/azurekit-and-cobol\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,32,36,37,38],"tags":[66,67,68,147,188],"_links":{"self":[{"href":"http:\/\/www.gennard.net\/blog\/wp-json\/wp\/v2\/posts\/712"}],"collection":[{"href":"http:\/\/www.gennard.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.gennard.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.gennard.net\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.gennard.net\/blog\/wp-json\/wp\/v2\/comments?post=712"}],"version-history":[{"count":0,"href":"http:\/\/www.gennard.net\/blog\/wp-json\/wp\/v2\/posts\/712\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.gennard.net\/blog\/wp-json\/wp\/v2\/media?parent=712"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.gennard.net\/blog\/wp-json\/wp\/v2\/categories?post=712"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.gennard.net\/blog\/wp-json\/wp\/v2\/tags?post=712"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}