This version is for Umbraco v8 only. For the v1 package for Umbraco v7 please visit the develop branch
For Umbraco v9 & v10 please goto https://github.com/umbraco/Umbraco.StorageProviders
An Azure Blob Storage IFileSystem provider for Umbraco Used to offload static files in the media section to the cloud.
This package allows the storage and retrieval of media items using Azure Blob Storage while retaining the relative paths to the files expected in the back office.
v2 & v3 require Umbraco v8.1.0+
Both NuGet and Umbraco packages are available. If you use NuGet but would like the benefit of the Umbraco configuration wizard you can install the Umbraco package first, use the wizard, then install the NuGet package, the configuration will be maintained.
NuGet Packages | Version | |
---|---|---|
Release Core | ||
Release Media | ||
Release Forms | ||
Bleeding edge Core | ||
Bleeding edge Media | ||
Bleeding edge Forms |
Umbraco Packages | |
---|---|
Release | |
Bleeding edge |
If you prefer, you can compile UmbracoFileSystemProviders.Azure yourself, you'll need:
To clone it locally click the "Clone in Windows" button above or run the following git commands.
git clone https://github.com/umbraco-community/UmbracoFileSystemProviders.Azure
cd UmbracoFileSystemProviders.Azure
.\build.cmd
In Web.config
create the new application keys
<add key="AzureBlobFileSystem.ConnectionString:media" value="DefaultEndpointsProtocol=https;AccountName=[myAccountName];AccountKey=[myAccountKey]" />
<add key="AzureBlobFileSystem.ContainerName:media" value="media" />
<add key="AzureBlobFileSystem.RootUrl:media" value="https://[myAccountName].blob.core.windows.net/" />
<add key="AzureBlobFileSystem.MaxDays:media" value="365" />
<add key="AzureBlobFileSystem.UseDefaultRoute:media" value="true" />
<add key="AzureBlobFileSystem.UsePrivateContainer:media" value="false" />
Additionally the provider can be further configured with the following application setting in the web.config
.
<?xml version="1.0"?>
<configuration>
<appSettings>
<!--Disables the built in Virtual Path Provider which allows for relative paths-->
<add key="AzureBlobFileSystem.DisableVirtualPathProvider" value="true" />
<!--
Enables the development mode for testing. Addition changes to the FileSystemProviders.config are also required
-->
<add key="AzureBlobFileSystem.UseStorageEmulator" value="true" />
</appSettings>
</configuration>
For Azure Key Vault only the key values in the Web.config
should use '-', rather than a '.' or ':' as shown below
<add key="AzureBlobFileSystem-ConnectionString-media" value="DefaultEndpointsProtocol=https;AccountName=[myAccountName];AccountKey=[myAccountKey]" />
<add key="AzureBlobFileSystem-ContainerName-media" value="media" />
<add key="AzureBlobFileSystem-RootUrl-media" value="https://[myAccountName].blob.core.windows.net/" />
<add key="AzureBlobFileSystem-MaxDays-media" value="365" />
<add key="AzureBlobFileSystem-UseDefaultRoute-media" value="true" />
<add key="AzureBlobFileSystem-UsePrivateContainer-media" value="false" />
By default the plugin will serve files transparently from your domain or serve media directly from Azure. This is made possible by using a custom Virtual Path Provider included and automatically initialised upon application startup. This can be disabled by adding the configuration setting noted above.
Note: Virtual Path Providers may affect performance/caching depending on your setup as the process differs from IIS's unmanaged handler. Virtual files sent via the provider though are correctly cached in the browser so this shouldn't be an issue. VPP providers also don't work with Precompiled sites or when used in a virtual directory/application.
The following configuration is required in your web.config
to enable static file mapping in IIS Express.
<?xml version="1.0"?>
<configuration>
<location path="Media">
<system.webServer>
<handlers>
<remove name="StaticFileHandler" />
<add name="StaticFileHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.StaticFileHandler" />
</handlers>
</system.webServer>
</location>
</configuration>
Also add this configuration to the web.config
inside the Media
folder
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers>
<clear />
<add name="StaticFileHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.StaticFileHandler" />
<add name="StaticFile" path="*" verb="*" modules="StaticFileModule,DefaultDocumentModule,DirectoryListingModule" resourceType="Either" requireAccess="Read" />
</handlers>
</system.webServer>
</configuration>
ImageProcessor.Web contains a IImageService
called CloudImageService
, to enable that service and pull images directly from
the cloud replace the CloudImageService
setting with the following:
<?xml version="1.0"?>
<security>
<services>
<service name="LocalFileImageService" type="ImageProcessor.Web.Services.LocalFileImageService, ImageProcessor.Web"/>
<service prefix="media/" name="CloudImageService" type="ImageProcessor.Web.Services.CloudImageService, ImageProcessor.Web">
<settings>
<setting key="Container" value="media"/>
<setting key="MaxBytes" value="8194304"/>
<setting key="Timeout" value="30000"/>
<setting key="Host" value="https://[myAccountName].blob.core.windows.net/"/>
</settings>
</service>
</services>
</security>
Note The CloudImageService
is not compatible with the FileSystemProvider when using private storage. You can instead use the AzureImageService
which is included with the AzureBlobCache package
Optionally install the AzureBlobCache plugin to get the most out of the package.
Currently this package is available only via NuGet
Install-Package UmbracoFileSystemProviders.Azure.Forms
In Web.config
update the new application keys with the required credentials
<add key="AzureBlobFileSystem.ContainerName:forms" value="forms-data" />
<add key="AzureBlobFileSystem.RootUrl:forms" value="https://[myAccountName].blob.core.windows.net/" />
<add key="AzureBlobFileSystem.ConnectionString:forms" value="DefaultEndpointsProtocol=https;AccountName=[myAccountName];AccountKey=[myAccountKey]" />
<add key="AzureBlobFileSystem.UsePrivateContainer:forms" value="false" />
The Azure Blob container cannot be called forms
as this will give unexpected behaviour, and we recommend you call it form-data
or similar.