In this blog post, we will go through how you can setup your Umbraco media files to use an Azure storage account. This process involves installing the NuGet package UmbracoFileSystemProviders.Azure.
Pre-requisites: Before proceeding below, make sure you already have an Azure Blob storage account with at least one container (i.e. media) and that you have access keys for this.
- Open Microsoft Azure Storage Explorer (download here if you don’t have it yet)
- On the prompt “Connect to Azure storage”, select “Use a storage account name and key”
- Enter the storage account name and one of the access keys
- Once connected, navigate to your storage account, and expand “Blob containers”. You should see all your containers like the below:
- Click on the container
- Navigate to where your Media files are in the file system. This is usually located on your Umbraco project root path > Media
- Select all folders including the web.config, drag and drop to the Azure Storage explorer to upload
- Your storage account container should now reflect all files you have on the file system
- On your Visual Studio, open package manager console (Tools > NuGet package manager)
- Run the command
Install-Package UmbracoFileSystemProviders.Azure
- Open config > FileSystemProviders.config and update the following
<add key="containerName" value="media"/> <add key="rootUrl" value="http://[YourStorageAccountName].blob.core.windows.net/"/> <add key="connectionString" value="DefaultEndpointsProtocol=https;AccountName=[YourStorageAccountName];AccountKey=[YourAccountKey]"/>
Your media files should now be connected to the Azure Storage account. Once you’ve verified your site still loads the images, you can then go ahead and delete your media files in the file system, 🙂