Kentico And Azure Integration Possibilities — Part 1 — Blob storage
In the world of “somebody else’s computer”, it is easy to get lost in all the tooling cloud providers give us, it is easy to be overwhelmed and decide not to use the new fancy stuff and rather build a workaround or the tooling you need yourself. We, the developers and architects developing any web solution love coding and building our own solutions.
In fact, we love developing our own solutions to typical problems so much we often forget that the purpose of our work is to provide business value to our clients and customers.
The purpose of this series of stories is to help you as a developer increase business value for your customers by choosing appropriate Azure solutions for typical workloads we do in the context of Kentico web sites and e-commerce solutions.
Wielding the hammer
When you have a hammer, everything looks like a nail. An often heard sentence in any life, especially in the life of a developer. Given a new tool, we tend to try finding uses cases for it in every project. While it is good to keep a tool in mind, people often try forcing it when it is not appropriate.
Take this paragraph as sort of a disclaimer. While I do advocate you consider using Azure services in every project, I do not advocate every project needs a Service Bus, Blob storage or any other tool.
Azure Blob Storage
Blob storage is a very efficient, cheap and easy to implement tool you can use on Kentico projects hosted on both Azure and On-Premise.
The purpose of the blob storage is storage of files (blobs). In the context of Kentico those are media library files. Storing media library files into blob storage instead of onto the apps file system brings many benefits.
The main benefit of using Blob storage is the independence between the App and the media files. This means that your deployment process can leverage deployment slots without the need to copy or synchronize the media library any other way. Both your pre-production and production apps will always point to the same blobs.
Other possible benefits are — the possibility of adding a CDN in the future and the availability and redundancy options that Azure provides.
Implementing blob storage for media storage
To implement this into your Kentico application you need to perform a few steps.
- Firstly, you need to create an Azure Storage account in your Azure subscription. You can do so by following the guide from Microsoft. A general purpose v2 storage account with Locally-Redundant storage should be appropriate for the majority of Kentico projects.
- After you have your storage account ready, you need to add the storage name and access key (select your storage account in Azure Portal and navigate to Access Keys) to your web.config file (on both the MVC and the admin application if your development model is MVC):
- You need to add a custom module class to your code base which will register the Azure provider with Kentico. The code in the documentation is fine to start, but here is our version with some modifications to make it more reusable.
If you use the MVC module, you will need to create this class in a separate class library and add it as a reference to both the MVC and CMS applications.
There are also additional configuration options available on the Kentico documentation
When NOT to use Azure Blob storage
In general, there is no harm in using blob storage on any Kentico project other than the slight bump in the hosting price that blob storage creates, which is negligible for any Kentico project other than the smallest ones.
I recommend not using blob storage for media library storage if you have the need for storing only a small amount of media files with small sizes and if you don’t plan on using deployment slots to deploy your application to production.
Additional uses for Azure Blob storage
Once you have your storage account in place and connected to your Kentico application, that doesn’t mean that this is the only and last benefit you could get from the storage. You can easily create another storage container and use it for another purpose.
While your purpose depends solely on your application, some use cases include but are not limited to:
- Sharing files between an external application and Kentico — Since blob storage is basically a REST API, any external service can be configured to store files on it regardless of development language and Kentico can pick up those files easily.
- Sharing files between different Kentico instances — You can create a container as sort of a “drop-in” zone for files between Kentico instances instead of sending files across via a Web API
- Using blob storage triggers for Azure functions or Logic Apps, to start up scheduled tasks or import processes.
I hope this was useful to some degree and gave you an idea on how and why you would use Azure Blob storage for your Kentico project.
If you have any questions or feedback, I’d be happy to hear from you!
This will be a multi-part series in which I will go over some more often used Azure tools and infrastructure that could help you with delivering great projects.
Check out the next part in the series: