In this tutorial, you will learn how to host your Umbraco media folder within Azure storage. For this tutorial, I am assuming you already have an Azure account, if not then head over to Azure and create an account.
Setting Up Azure With Your Umbraco Files
In this section, we will first create an Azure blob storage container. To create some storage within Azure, log-into the Azure portal and go to the Storage Account Page and then create a new account. After creating an account you should be given an account name and an API access key. Keep a note of these as you will need them shortly.
Next, we will need a way to manage the existing media library assets and transfer them into Azure. The easiest way to do this is to download Azure Storage Explorer. After connecting to the storage using the name and the API access key, you will have an active connection to your storage bucket. To copy your media files into Azure, within your website's webroot drag all the contents within the media folder and drag them into the Azure file storage account.
After a few minutes and the explorer should refresh with all your changes in it.
Configuring Umbraco To Use Azure storage
Next, we will need to configure Umbraco to use our new cloud storage rather than the file system. First, you need to install UmbracoFileSystemProviders.Azure
. Within Visual Studio, open the package manager console:
Run this command:
To configure Umbraco to use a different file system provider, we will have to modify some config within the filesystemprovider.config
file. The fileSystemProviders.config
contains all the configurations that tell Umbraco to interact with file systems. If you want to read a little more about this you can view the official Umbraco documentation [here]. https://our.umbraco.com/documentation/Reference/Config/fileSystemProviders/). You can find this file within the 'config' folder ➡ 'filesystemprovider.config'. By default, the config will be set to use Umbraco local storage. The config file should look similar to this:
To configure Azure you will need to update/add containerName
, rootUrl
and connection string
values. You can find the Azure storage connectionString
details within the Azure portal if you get stuck!
After copying all your media into Azure storage, installing the package and updating the config. When you reset the site and try to load it, your site should be working correctly and all your images should load. If you really want to you can safely delete all the files within your webroot files system now as they will no longer be used (make a backup first). Happy Coding 🤘