{"id":495,"date":"2017-04-08T08:16:54","date_gmt":"2017-04-08T08:16:54","guid":{"rendered":"http:\/\/www.rangakrish.com\/?p=495"},"modified":"2017-04-08T10:46:21","modified_gmt":"2017-04-08T10:46:21","slug":"accessing-azure-blobs-in-lisp","status":"publish","type":"post","link":"https:\/\/www.rangakrish.com\/index.php\/2017\/04\/08\/accessing-azure-blobs-in-lisp\/","title":{"rendered":"Accessing Azure BLOBs in Lisp"},"content":{"rendered":"<p>Recently I was looking for a Common Lisp library for accessing Azure services. Azure has official SDKs in many languages, but Lisp is not one of them. Quite understandable and I have no complaints. Because the services are all exposed via REST interfaces, it should not be difficult to implement a Lisp wrapper to use the services. Before writing one myself, I wanted to see if someone has already done the work. My search led me to <a href=\"https:\/\/github.com\/RobBlackwell\/cl-azure\" target=\"_blank\"><em><strong>cl-azure<\/strong><\/em><\/a>. This library seems to focus on Azure Storage Resource, but that is a good start.<\/p>\n<p>Basic documentation is available <a href=\"http:\/\/quickdocs.org\/cl-azure\/api\" target=\"_blank\"><em><strong>here<\/strong><\/em><\/a>. The implementation is a few years old and does not have support for File Storage. Even the functionality available for existing containers is not complete. But then, it is not hard to extend the functionality.<\/p>\n<p>For today\u2019s post, I am only focussing on BLOB-related functionality built into the library.<\/p>\n<p>I am using Allegro CL on my Mac for this experiment. The simplest way to get the library is using <a href=\"https:\/\/www.quicklisp.org\/beta\/\" target=\"_blank\"><em><strong>Quicklisp<\/strong><\/em><\/a>.<\/p>\n<p>The first step is to set up the account name and credentials. The library requires that we define a list of key-value pairs for the different resource types namely, BLOB, Table and Queue (File Storage is not supported). For convenience, I defined a function to generate the correct URL from account name and container type.<\/p>\n<p>Fig.1 shows the Listener with some commands I executed.<\/p>\n<figure id=\"attachment_496\" aria-describedby=\"caption-attachment-496\" style=\"width: 651px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2017\/04\/Fig.1.png\"><img data-recalc-dims=\"1\" fetchpriority=\"high\" decoding=\"async\" data-attachment-id=\"496\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2017\/04\/08\/accessing-azure-blobs-in-lisp\/fig-1-2\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2017\/04\/Fig.1.png\" data-orig-size=\"991,719\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Fig.1\" data-image-description=\"&lt;p&gt;Fig.1&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Fig.1&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2017\/04\/Fig.1.png\" class=\"wp-image-496\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2017\/04\/Fig.1.png?resize=651%2C472\" alt=\"Fig.1\" width=\"651\" height=\"472\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2017\/04\/Fig.1.png?w=991&amp;ssl=1 991w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2017\/04\/Fig.1.png?resize=300%2C218&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2017\/04\/Fig.1.png?resize=768%2C557&amp;ssl=1 768w\" sizes=\"(max-width: 651px) 100vw, 651px\" \/><\/a><figcaption id=\"caption-attachment-496\" class=\"wp-caption-text\">Fig.1<\/figcaption><\/figure>\n<p>&nbsp;<\/p>\n<p>The <em><strong>list-containers<\/strong><\/em>\u00a0function enumerates the different BLOB containers associated with the given account (I would have preferred the name <em><strong>list-blob-containers<\/strong><\/em>). For a given BLOB container, the function <em><strong>list-blobs<\/strong><\/em> returns all the blobs in that container. If you have a BLOB that contains textual data, the function <em><strong>get-blob-string<\/strong><\/em> is useful to fetch the content as a string.<\/p>\n<p>The function <em><strong>put-blob<\/strong><\/em> allows you to create (or update) a BLOB with some data. Deleting a BLOB is also easy: the function <em><strong>delete-blob<\/strong><\/em> does just that. If you have a BLOB that you need to copy to your local file system, you can use the function <em><strong>get-blob-file<\/strong><\/em>. Fig. 2 shows these commands in action.<\/p>\n<figure id=\"attachment_497\" aria-describedby=\"caption-attachment-497\" style=\"width: 650px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2017\/04\/Fig.2.png\"><img data-recalc-dims=\"1\" decoding=\"async\" data-attachment-id=\"497\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2017\/04\/08\/accessing-azure-blobs-in-lisp\/fig-2-2\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2017\/04\/Fig.2.png\" data-orig-size=\"1327,457\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Fig.2\" data-image-description=\"&lt;p&gt;Fig.2&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Fig.2&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2017\/04\/Fig.2-1024x353.png\" class=\"wp-image-497\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2017\/04\/Fig.2-1024x353.png?resize=650%2C224\" alt=\"Fig.2\" width=\"650\" height=\"224\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2017\/04\/Fig.2.png?resize=1024%2C353&amp;ssl=1 1024w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2017\/04\/Fig.2.png?resize=300%2C103&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2017\/04\/Fig.2.png?resize=768%2C264&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2017\/04\/Fig.2.png?w=1327&amp;ssl=1 1327w\" sizes=\"(max-width: 650px) 100vw, 650px\" \/><\/a><figcaption id=\"caption-attachment-497\" class=\"wp-caption-text\">Fig.2<\/figcaption><\/figure>\n<p>Overall, using the library seems to be intuitive and straightforward. Of course, not all functionality is currently implemented by this library. Support for <strong>File Storage<\/strong> is missing and is badly needed. However, given the source code, it is not difficult to add the needed functionality. This is something I will explore in the future.<\/p>\n<p>If you want the test commands\u00a0I wrote, download <a href=\"http:\/\/www.rangakrish.com\/downloads\/Azure Storage Example.cl\" target=\"_blank\"><em><strong>this file<\/strong><\/em><\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Recently I was looking for a Common Lisp library for accessing Azure services. Azure has official SDKs in many languages, but Lisp is not one of them. Quite understandable and I have no complaints. Because the services are all exposed via REST interfaces, it should not be difficult to implement a Lisp wrapper to use [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"advanced_seo_description":"","jetpack_seo_html_title":"","jetpack_seo_noindex":false,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[18,17],"tags":[95,19],"class_list":["post-495","post","type-post","status-publish","format-standard","hentry","category-lisp","category-programming","tag-azure","tag-lisp"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p9OLnF-7Z","jetpack-related-posts":[{"id":506,"url":"https:\/\/www.rangakrish.com\/index.php\/2017\/04\/23\/accessing-azure-tables-in-lisp\/","url_meta":{"origin":495,"position":0},"title":"Accessing Azure Tables in Lisp","author":"admin","date":"April 23, 2017","format":false,"excerpt":"In the previous post, we saw how to use cl-azure\u00a0to access Azure storage, in particular, BLOBs. Today we will experiment with Tables. The following operations are currently supported by the library: - Create a new table - List all the tables available - Add rows to a table - List\u2026","rel":"","context":"In &quot;LISP&quot;","block_context":{"text":"LISP","link":"https:\/\/www.rangakrish.com\/index.php\/category\/lisp\/"},"img":{"alt_text":"Create Table","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2017\/04\/Fig.1-1-1024x501.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2017\/04\/Fig.1-1-1024x501.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2017\/04\/Fig.1-1-1024x501.png?resize=525%2C300 1.5x"},"classes":[]},{"id":2334,"url":"https:\/\/www.rangakrish.com\/index.php\/2021\/02\/28\/calling-c-methods-from-lispworks-lisp-through-com-interface\/","url_meta":{"origin":495,"position":1},"title":"Calling C# Methods from LispWorks Lisp through COM Interface","author":"admin","date":"February 28, 2021","format":false,"excerpt":"In an earlier article, I showed how to invoke C# methods from Sicstus Prolog. Today, I would like to detail the steps for doing the same from LispWorks Lisp. LispWorks Enterprise Edition comes budled with support for COM and Automation. This is what we will be using. What this means\u2026","rel":"","context":"In &quot;LISP&quot;","block_context":{"text":"LISP","link":"https:\/\/www.rangakrish.com\/index.php\/category\/lisp\/"},"img":{"alt_text":"The COM Server in C#","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2021\/02\/C-Code-300x267.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":2406,"url":"https:\/\/www.rangakrish.com\/index.php\/2021\/05\/09\/eager-future2-common-lisp-library\/","url_meta":{"origin":495,"position":2},"title":"Eager Future2 Common Lisp Library","author":"admin","date":"May 9, 2021","format":false,"excerpt":"Eager Future2 is a Common Lisp library that facilitates parallel computation. It is based on the idea of a \u201cfuture\u201d that acts as a \u201cproxy\u201d for a concurrently computed expression. Unlike the \u201clparallel\u201d library that I had discussed in the last article, this library does not give us control over\u2026","rel":"","context":"In &quot;LISP&quot;","block_context":{"text":"LISP","link":"https:\/\/www.rangakrish.com\/index.php\/category\/lisp\/"},"img":{"alt_text":"Fibonacci Calculation - 3 Ways","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2021\/05\/Code-232x300.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":2057,"url":"https:\/\/www.rangakrish.com\/index.php\/2020\/07\/19\/calling-lisp-functions-from-elixir\/","url_meta":{"origin":495,"position":3},"title":"Calling Lisp Functions from Elixir","author":"admin","date":"July 19, 2020","format":false,"excerpt":"In the last article\u00a0I showed how we can simulate the idea of Lisp's \"closure\" in Elixir. Today, I would like to demonstrate how we can call Lisp functions from Elixir using the NIF interface. What is the need to integrate Elixir with another language? I can think of two reasons:\u2026","rel":"","context":"In &quot;Elixir&quot;","block_context":{"text":"Elixir","link":"https:\/\/www.rangakrish.com\/index.php\/category\/elixir\/"},"img":{"alt_text":"Using the Lisp Functions","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2020\/07\/Session.jpg?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2020\/07\/Session.jpg?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2020\/07\/Session.jpg?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2020\/07\/Session.jpg?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":1517,"url":"https:\/\/www.rangakrish.com\/index.php\/2019\/03\/28\/ocr-using-azure-computer-vision-api\/","url_meta":{"origin":495,"position":4},"title":"OCR Using Azure Computer Vision API","author":"admin","date":"March 28, 2019","format":false,"excerpt":"I have been getting some good feedback on Azure\u2019s Computer Vision API, in particular, the OCR functionality. Although I am not working on any project that requires this functionality at the moment, I thought it would be a good idea to check out the service - just to be \u201cfuture\u2026","rel":"","context":"In &quot;Image Processing&quot;","block_context":{"text":"Image Processing","link":"https:\/\/www.rangakrish.com\/index.php\/category\/image-processing\/"},"img":{"alt_text":"Converted Text","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/03\/Converted-1.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/03\/Converted-1.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/03\/Converted-1.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":3312,"url":"https:\/\/www.rangakrish.com\/index.php\/2024\/01\/28\/the-hy-programming-language\/","url_meta":{"origin":495,"position":5},"title":"The Hy Programming Language","author":"admin","date":"January 28, 2024","format":false,"excerpt":"In an earlier article\u00a0I had explained how to execute Python code from within Common Lisp using \u201cCLPython\u201d package. In contrast to that approach, \u201cHy\u201d\u00a0is a Lisp-style language (not compatible with Common Lisp) that is embedded in Python and hence provides seamless interoperability with Python code. Installation is straightforward (it is\u2026","rel":"","context":"In &quot;Hy Language&quot;","block_context":{"text":"Hy Language","link":"https:\/\/www.rangakrish.com\/index.php\/category\/hy-language\/"},"img":{"alt_text":"Hy REPL","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2024\/01\/console-300x148.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]}],"_links":{"self":[{"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/posts\/495","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/comments?post=495"}],"version-history":[{"count":0,"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/posts\/495\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/media?parent=495"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/categories?post=495"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/tags?post=495"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}