Working with Azure Blob Storage

When I implemented the original image storage functionality for the mobile app by developing an ASP.NET Web API service, I knew that ultimately I wanted this functionality to use Azure Blob Storage (ABS). We already use many other Azure services (Service Bus, Functions, WebJobs etc) and so it seemed a natural fit to also use Azure for storing the images sent from the mobile app.

Initially I wasn’t sure how ABS would integrate with our Web API services from an architectural point-of-view. After some advice from some highly respected colleagues (you know who you are — Andy Deacon and Steve Evans), the simplest and most effective approach would be for the mobile app to upload the images to ABS, then pass the blob ID into the backend service as part of the message that is created by the mobile app (all form submission data that is sent from the mobile app is packaged up into a message object which contains all the user-entered information). So with this in mind, I began exploring how this could be achieved.

Unfortunately, due to the pressures of timescales, I didn’t have sufficient time to implement a solution using ABS. I wasn’t familiar enough with it, and needed to spend some time researching around it and getting to grips with it. Maybe go through some example code and read through the documentation.

Now that I’ve finally managed to get round to this, I’ve managed to develop a complete suite of ASP.NET Web API services for uploading, downloading, listing and deleting blobs from ABS. And yet again, I am very impressed by just how rich the API is for integrating our Web API services with Azure. Setting up and configuring the ABS containers was straight-forward. I created one for unit-testing and one for production. I added the ABS connection strings and container names to the web.config file (you don’t want this hard-coded into your application code). I then created the necessary Web API controllers (and associated unit-tests) for allowing the mobile app to integrate with ABS.

The images are uploaded as serialised JSON objects (to enable the mobile app to consume the services), which are de-serialised by the Web API controllers. Once de-serialised into a type that is capable of integrating with ABS (such as a file stream), the necessary ABS API methods are invoked.

As I have come to expect from Azure, all of this functionality works seamlessly with the .NET ecosystem. The infrastructure for integrating with ABS is now code complete. All that is left now is to make the necessary changes to the mobile app to support these new services. These will be rolled out when we begin working on the new version of the mobile app (timescales TBD).

Azure is one of the best development platforms I have used in a long while. It’s extremely powerful, has full support with Visual Studio and the .NET ecosystem, and is easy to setup and configure.

If you’re building high volume enterprise applications which need to be scalable and available, then Azure is definitely worth a look.

If this article was helpful to you, please do hit the 💚 button below. Thanks!

A father, cyclist, vegetarian, atheist, geek and multiple award winning technical author. Loves real ale, fine wine and good music. All round decent chap.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store