This repository contains Umbraco storage providers that can replace the default physical file storage.
The Azure Blob Storage provider has an implementation of the Umbraco IFileSystem
that connects to an Azure Blob Storage container.
It also has the following features:
- middleware for serving media files from the
/media
path - ImageSharp image provider/cache
- a CDN media URL provider
This provider can be added in the Startup.cs
file:
public void ConfigureServices(IServiceCollection services)
{
services.AddUmbraco(_env, _config)
.AddBackOffice()
.AddWebsite()
.AddComposers()
// Add the Azure Blob Storage file system, ImageSharp image provider/cache and middleware for Media:
.AddAzureBlobMediaFileSystem()
// Optionally add the CDN media URL provider:
.AddCdnMediaUrlProvider()
.Build();
}
public void Configure(IApplicationBuilder app)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseUmbraco()
.WithMiddleware(u =>
{
u.UseBackOffice();
u.UseWebsite();
// Enables the Azure Blob Storage middleware for Media:
u.UseAzureBlobMediaFileSystem();
})
.WithEndpoints(u =>
{
u.UseInstallerEndpoints();
u.UseBackOfficeEndpoints();
u.UseWebsiteEndpoints();
});
}
There're multiple ways to configure the provider, it can be done in code:
services.AddUmbraco(_env, _config)
.AddAzureBlobMediaFileSystem(options => {
options.ConnectionString = "";
options.ContainerName = "";
})
.AddCdnMediaUrlProvider(options => {
options.Url = new Uri("https://my-cdn.example.com/");
});
In appsettings.json
:
{
"Umbraco": {
"Storage": {
"AzureBlob": {
"Media": {
"ConnectionString": "",
"ContainerName": "",
"Cdn": {
"Url": ""
}
}
}
}
}
}
Or by environment variables:
UMBRACO__STORAGE__AZUREBLOB__MEDIA__CONNECTIONSTRING=<CONNECTION_STRING>
UMBRACO__STORAGE__AZUREBLOB__MEDIA__CONTAINERNAME=<CONTAINER_NAME>
UMBRACO__STORAGE__AZUREBLOB__MEDIA__CDN__URL=<CDN_BASE_URL>
Note: you still have to add the provider in the Startup.cs
file when not configuring the options in code.
The container name is expected to exist and uses the following folder structure:
/media
- contains the Umbraco media, stored in the structure defined by theIMediaPathScheme
registered in Umbraco (the defaultUniqueMediaPathScheme
stores files with their original filename in 8 character directories, based on the content and property GUID identifier)/cache
- contains the ImageSharp image cache, stored as files with a filename defined by theICacheHash
registered in ImageSharp (the defaultCacheHash
generates SHA256 hashes of the file contents and uses the first characters configured by theUmbraco:CMS:Imaging:CachedNameLength
setting)
Note that this is different than the behavior of other file system providers - i.e. https://github.com/umbraco-community/UmbracoFileSystemProviders.Azure that expect the media contents to be at the root level.
If you encounter a bug when using this client library you are welcome to open an issue in the issue tracker of this repository. We always welcome Pull Request and please feel free to open an issue before submitting a Pull Request to discuss what you want to submit.
Questions about usage should be posted to the forum on our.umbraco.com.
Umbraco Storage Providers is MIT licensed.