Umbraco.StorageProviders.AzureBlob v9 wrong path for CDN images
Hi All,
**summary version: When using CDN, the URL returned appears to be incorrect.
I'm using the HQ package Umbraco.StorageProviders.AzureBlob (https://github.com/umbraco/Umbraco.StorageProviders) to serve media from Azure for my site, but when using the CDN I'm having issues.
When I view images in the back office all is fine. When I upload images I can see they get added to the Azure storage account and I can see in the cache folder they're created there too.
When I try and get an image back without using the CDN it works fine; e.g. it'll return:
"https://localhost:44330/media/hacjqvy5/design.jpg"
So that image is on Azure in my storage account but it's not using the CDN to pull it back. Fine.
Now when I try to return and image using the CDN (E.g. calling the URL of an image on a page) the following URL is returned - this doesn't work.
"https://myAzureCdnUrl.net//hacjqvy5/design.jpg"
When looking in my storage account I can see the following:
Container:
Umbraco
Within the Umbraco container > Media and Cache
Within Media > folder called hacjqvy5 which contains design.jpg
Within Cache various files with unique 8 digit file names (no extensions) of content type octet-stream
Does anyone know what I'm doing wrong? (I used to use V7 Blob & azure CDN lots, without issue BTW)
Within Startup I have the connectionstring set, the container name set as "Umbraco" as per the above structure and my Azure CDN endpoint URL in the CDN URL field.
We use Azure Storage and Azure CDN for both Umbraco 8 and 9 using the official/recommended packages.
So we technically never emit (or generate) absolute media URLs, we always generate CDN URLs. We use GetCropUrl() to emit imgsrcs for example. So I can't say 100% that generating "URLs to media" work, only that generating "CDN URLs to media" works.
Everything works out of the box after configuring the Storage and CDN settings:
if (!_env.IsDevelopment())
{
// Add the Azure Blob Storage file system, ImageSharp image provider/cache and middleware for Media:
u.AddAzureBlobMediaFileSystem()
// Optionally add the CDN media URL provider:
.AddCdnMediaUrlProvider(options =>
{
var settings = _config.GetSection("Umbraco:Storage:AzureBlob:Media:Cdn");
options.Url = new Uri(settings.GetValue<string>("Url"));
});
}
The CDN endpoint is set to fetch origin media from https://site/media/, so you could say the actual media URL pattern is hard-coded into the CDN configuration.
Why configuring the CDN media URL provider is necessary I can't recall, but the emitted CDN media URL was broken somehow. It was either lacking an URL segment or containing a superfluous URL segment.
It looks like you're only missing the media segment in the CDN URL. We don't use that segment. So if you just add /media to your CDN URL it looks like it should work.
In the older storage providers the cache folder used to house copies of the media when it was requested; but I'm not seeing that within my cache folder on blob storage.
The structure of my cache folder on blob storage is as follows:
Umbraco > Cache > files (e.g. "445ffae" with no extension and a content type of application/octet-stream). That's quite different to what I used successfully many times in terms of older versions of the storage provider when it was pulling images back via the CDN.
Umbraco.StorageProviders.AzureBlob v9 wrong path for CDN images
Hi All,
**summary version: When using CDN, the URL returned appears to be incorrect.
I'm using the HQ package Umbraco.StorageProviders.AzureBlob (https://github.com/umbraco/Umbraco.StorageProviders) to serve media from Azure for my site, but when using the CDN I'm having issues.
When I view images in the back office all is fine. When I upload images I can see they get added to the Azure storage account and I can see in the cache folder they're created there too.
When I try and get an image back without using the CDN it works fine; e.g. it'll return: "https://localhost:44330/media/hacjqvy5/design.jpg" So that image is on Azure in my storage account but it's not using the CDN to pull it back. Fine.
Now when I try to return and image using the CDN (E.g. calling the URL of an image on a page) the following URL is returned - this doesn't work. "https://myAzureCdnUrl.net//hacjqvy5/design.jpg"
When looking in my storage account I can see the following:
Container: Umbraco
Within the Umbraco container > Media and Cache
Within Media > folder called hacjqvy5 which contains design.jpg
Within Cache various files with unique 8 digit file names (no extensions) of content type octet-stream
Does anyone know what I'm doing wrong? (I used to use V7 Blob & azure CDN lots, without issue BTW) Within Startup I have the connectionstring set, the container name set as "Umbraco" as per the above structure and my Azure CDN endpoint URL in the CDN URL field.
Thanks!
Anyone managing to successfully use Umbraco.StorageProviders on Umb v9 with an Azure CDN?
We use Azure Storage and Azure CDN for both Umbraco 8 and 9 using the official/recommended packages.
So we technically never emit (or generate) absolute media URLs, we always generate CDN URLs. We use
GetCropUrl()
to emitimg
src
s for example. So I can't say 100% that generating "URLs to media" work, only that generating "CDN URLs to media" works.Everything works out of the box after configuring the Storage and CDN settings:
In
Startup.ConfigureServices()
:The CDN endpoint is set to fetch origin media from
https://site/media/
, so you could say the actual media URL pattern is hard-coded into the CDN configuration.Why configuring the CDN media URL provider is necessary I can't recall, but the emitted CDN media URL was broken somehow. It was either lacking an URL segment or containing a superfluous URL segment.
Hmm ok thanks. I'll take another look. Currently my startup looks like so:
It looks like you're only missing the
media
segment in the CDN URL. We don't use that segment. So if you just add/media
to your CDN URL it looks like it should work.Unfortunately that doesn't work either.
In the older storage providers the cache folder used to house copies of the media when it was requested; but I'm not seeing that within my cache folder on blob storage.
The structure of my cache folder on blob storage is as follows: Umbraco > Cache > files (e.g. "445ffae" with no extension and a content type of application/octet-stream). That's quite different to what I used successfully many times in terms of older versions of the storage provider when it was pulling images back via the CDN.
Did you ever find a solution to this?
I'm curious also. I'm seeing the same behavior after I moved my app service from Windows to Linux
is working on a reply...