Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Dhanesh Kumar MJ 165 posts 521 karma points MVP c-trib
    Jan 22, 2022 @ 18:29
    Dhanesh Kumar MJ
    0

    Image is not getting cropped via Azure CDN

    Hi,

    Setupped the site to use Azure Blob Storage for Media, and it's working fine, but when we try to serve media via CDN, then it is not working as expected.

    The Media cropper is not working via CDN URL.

    CDN URL

    CDN Profile screenshots - Cache every Unique URL enter image description here

    Regards
    Dhanesh

  • Marc Goodson 2155 posts 14408 karma points MVP 9x c-trib
    Jan 22, 2022 @ 20:45
    Marc Goodson
    1

    Hi Dhanesh

    Is the CDN set up direct to the blob folder or via your website?

    So if a request comes into the CDN...

    https://cdn.mysite.com/media/1234/myimage.jpg?width=150

    Then this should request the image via the website eg.

    https://www.mysite.com/media/myimage.jpg?width=150

    This enables ImageSharp to resize the image and return this processed image back to the CDN which caches it for subsequent requests hence needing the cache each url uniquely option you highlight to be turned on...

    Common issues are usually that the CDN is set up directly to blob storage... And so there is nothing to handle the resize request! Or the cache unique checkbox isn't ticked when the CDN is first launched and so the CDN needs to be purged for the change to take affect!

    Regards

    Marc

  • Dhanesh Kumar MJ 165 posts 521 karma points MVP c-trib
    Jan 23, 2022 @ 16:56
    Dhanesh Kumar MJ
    0

    Thanks Marc,

    Ah, I got it, I change the origin of the CDN profile to the WebApp instead of Blob Storage and now the media is getting cropped.

    There is a small issue with the package, the container name is automatically appended along with the CDN URL because of this

    eg: https://cdn.url/containername/media... and return 404.

    But we can fix this by configuring the AddCdnMediaUrlProvider, it takes a callback where I can configure the options like below.

    services.AddUmbraco(_env, _config)
    
        .AddAzureBlobMediaFileSystem(options => {
            options.ConnectionString = "";
            options.ContainerName = "";
        })
    
        .AddCdnMediaUrlProvider(options => {
            options.Url = new Uri("https://my-cdn.example.com/");
        });
    

    Regards
    Dhanesh

Please Sign in or register to post replies

Write your reply to:

Draft