Accessing Azure BLOBs in Lisp

Written by on April 8, 2017 in LISP, Programming with 0 Comments

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 cl-azure. This library seems to focus on Azure Storage Resource, but that is a good start.

Basic documentation is available here. 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.

For today’s post, I am only focussing on BLOB-related functionality built into the library.

I am using Allegro CL on my Mac for this experiment. The simplest way to get the library is using Quicklisp.

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.

Fig.1 shows the Listener with some commands I executed.




The list-containers function enumerates the different BLOB containers associated with the given account (I would have preferred the name list-blob-containers). For a given BLOB container, the function list-blobs returns all the blobs in that container. If you have a BLOB that contains textual data, the function get-blob-string is useful to fetch the content as a string.

The function put-blob allows you to create (or update) a BLOB with some data. Deleting a BLOB is also easy: the function delete-blob does just that. If you have a BLOB that you need to copy to your local file system, you can use the function get-blob-file. Fig. 2 shows these commands in action.



Overall, using the library seems to be intuitive and straightforward. Of course, not all functionality is currently implemented by this library. Support for File Storage 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.

If you want the test commands I wrote, download this file.

Tags: ,


If you enjoyed this article, subscribe now to receive more just like it.

Subscribe via RSS Feed

Leave a Reply

Your email address will not be published. Required fields are marked *