Orchard Core Azure Media Storage
Module Overview
The OrchardCore.Media.Azure module stores media in Azure Blob Storage instead
of App_Data:
OrchardCore.Media.Azure.Storage— replaces the media store with Blob Storage. Depends on (and enables)OrchardCore.Media.Cache.OrchardCore.Media.Azure.ImageCache— stores resized images in Blob Storage instead ofwwwroot/{tenant}/media-cache.
Media is still served by the Orchard Core site: the Media Cache fetches blobs on
demand, which keeps on-the-fly resizing working, and AssetUrl helpers point to
the site (or to Media:CdnBaseUrl). Only one storage provider is active at a
time.
{
"steps": [
{
"name": "Feature",
"enable": [
"OrchardCore.Media.Azure.Storage",
"OrchardCore.Media.Azure.ImageCache"
],
"disable": []
}
]
}
Azure Media Storage (`OrchardCore:Media:Azure`)
| Property | Description | Default |
|---|---|---|
| ConnectionString | Storage account connection string (required). | |
| ContainerName | Container name, a valid lowercase DNS name. Templatable. | |
| BasePath | Optional sub-path inside the container. Templatable. | |
| CreateContainer | Create the container on tenant activation if missing. | true |
| RemoveContainer | Delete the container when the tenant is removed. | false |
| UseHierarchicalNamespace | Force Gen2 (true) or Gen1 (false) behavior. Leave unset to auto-detect. | unset |
{
"OrchardCore": {
"Media": {
"Azure": {
"ConnectionString": "DefaultEndpointsProtocol=https;AccountName=myaccount;AccountKey=mykey;EndpointSuffix=core.windows.net",
"ContainerName": "media",
"BasePath": "Media",
"CreateContainer": true,
"RemoveContainer": false
}
}
}
}
- Environment variables:
OrchardCore__Media__Azure__ConnectionString,OrchardCore__Media__Azure__ContainerName. - Azure Key Vault secret names (see
orchardcore-azure-key-vault):OrchardCore--Media--Azure--ConnectionString. - With a missing or invalid connection string the feature does not activate and an error is logged; media falls back to the file system.
- Set
CreateContainertofalsewhen the container is pre-provisioned to skip the startup check.
Hierarchical namespace (ADLS Gen2)
BlobFileStore(Azure media and Azure Shells configuration) supports flat (Gen1) and hierarchical namespace (HNS / ADLS Gen2) accounts.- The store probes the account with
GetAccountInfo(also during tenant activation). With HNS, directory create/delete and file moves use native Data Lake APIs: atomic moves and real directories. Gen1 keeps the marker-file directory emulation. - Auto-detection needs account-level permissions and fails with a container-scoped SAS token; then set
UseHierarchicalNamespaceexplicitly. - The DFS endpoint is derived from the connection string; no extra setting.
- The gallery storage info popover reports hierarchical namespace and atomic move support.
{
"OrchardCore": {
"Media": {
"Azure": {
"ConnectionString": "BlobEndpoint=https://myaccount.blob.core.windows.net/;SharedAccessSignature=sv=...",
"ContainerName": "media",
"CreateContainer": false,
"UseHierarchicalNamespace": true
}
}
}
}
Tenant Templating
ContainerNameandBasePathaccept Liquid withShellSettingsin scope.{{ ShellSettings.Name }}is lowercased; the full name must still follow Azure naming rules.- Only default Liquid filters and tags are available (no
slugify).
{
"OrchardCore": {
"Media": {
"Azure": {
"ConnectionString": "DefaultEndpointsProtocol=https;AccountName=myaccount;AccountKey=mykey;EndpointSuffix=core.windows.net",
"ContainerName": "{{ ShellSettings.Name }}-media",
"BasePath": "Media",
"CreateContainer": true
}
}
}
}
Single container with a folder per tenant:
{
"OrchardCore": {
"Media": {
"Azure": {
"ConnectionString": "DefaultEndpointsProtocol=https;AccountName=myaccount;AccountKey=mykey;EndpointSuffix=core.windows.net",
"ContainerName": "sharedmedia",
"BasePath": "{{ ShellSettings.Name }}/Media",
"CreateContainer": true
}
}
}
}
Media Cache
- Enabled automatically with Azure Media Storage. Files fetched from Blob Storage are cached locally so they can be resized and served.
- Settings → Media → Cache (permission
MediaPermissions.ManageAssetCache) offers a Purge action. Local remote-media files live inwwwroot/{tenant}/ms-cache. - When fronted by a CDN, purge only after the CDN has fetched most assets. Each CDN PoP caches independently and CDNs evict on their own schedule, so the Media Cache must always be able to re-fetch from the container.
Azure Media Image Cache (`OrchardCore:Media:Azure:ImageCache`)
Stores resized images in Blob Storage (AzureBlobResizedImageCache, options
MediaBlobImageCacheOptions). Useful with ephemeral file systems (containers,
clean deployments) and throttled local disks (App Service).
| Property | Description | Default |
|---|---|---|
| ConnectionString | Storage account connection string (required). | |
| ContainerName | Cache container. Templatable. | |
| BasePath | Sub-path inside the container. Templatable. | |
| CreateContainer | Create the container if missing. | true |
| RemoveContainer | Delete the container when the tenant is removed. | false |
| RemoveFilesFromBasePath | Delete files under BasePath on tenant removal when RemoveContainer is false. | false |
{
"OrchardCore": {
"Media": {
"Azure": {
"ImageCache": {
"ConnectionString": "DefaultEndpointsProtocol=https;AccountName=myaccount;AccountKey=mykey;EndpointSuffix=core.windows.net",
"ContainerName": "imagecache",
"BasePath": "{{ ShellSettings.Name }}",
"CreateContainer": true,
"RemoveContainer": false,
"RemoveFilesFromBasePath": true
}
}
}
}
}
- Environment variable:
OrchardCore__Media__Azure__ImageCache__ConnectionString. - Cache files are only removed with the tenant when each tenant has its own container, or with
RemoveFilesFromBasePath. - The feature replaces
IResizedImageCacheonly whenConnectionStringandContainerNameare valid; otherwise the localmedia-cachefolder stays in use and an error is logged.
Resumable Uploads
When OrchardCore.Media.Tus is also enabled, TUS partial uploads are staged as
uncommitted blocks (AzureBlobTusTempStore) under a _tus-uploads prefix of
the media container, so any instance can continue an upload without a shared
temp folder. Without a valid Azure configuration, TUS keeps using the local
temp directory. See orchardcore-media-gallery for TUS, SignalR and
multi-instance guidance.
Upgrading from 3.x
- Rename
OrchardCore_Media_AzuretoMedia:AzureandOrchardCore_Media_Azure_ImageSharp_CachetoMedia:Azure:ImageCache, including env vars (OrchardCore__OrchardCore_Media_Azure__ConnectionString→OrchardCore__Media__Azure__ConnectionString) and Key Vault secrets. The old names are deprecated but still read; the new name wins when both exist. - Use the feature ID
OrchardCore.Media.Azure.ImageCachein recipes. The obsoleteOrchardCore.Media.Azure.ImageSharpImageCacheID only enables the new feature. ImageSharpBlobImageCacheOptionsis nowMediaBlobImageCacheOptions, and the cache is anIResizedImageCacheused by the built-in NetVips pipeline (no ImageSharp.Web).- Gen2 accounts now get atomic moves and real directories automatically; set
UseHierarchicalNamespacewhen connecting with a container-scoped SAS.