Azure CDN and Content Staging

Joel Dahlin asked on September 9, 2015 21:17

I am looking to see if anyone has or is using the Azure CDN with Content Staging in Kentico? Does this work? For example if you add a new image in Staging and then add a reference to that image in a page how is this handled when synching to Production? Can you synch media libraries to push to the PROD CDN and also is the reference to this updated?

Correct Answer

Bryan Soltis answered on September 9, 2015 23:38

Well, if you use the local file system in Staging, you will end up having paths that will not include your CDN path when you sync them to PROD. This will require those links to be updated again. Having your STAGING server configured may not be an option, but unless you do it, your PROD server will always treat the content as generic text and sync whatever it is, the relative path in that case (not the CDN path).

As for the paths, using the direct link (not the /getmedia/.. path) will be better for SEO, but you will encounter an issue when it's synced because those files will not be on the local disk in your PROD environment. The "Permanent URL" (/getmedia/...) is great for portability (because the same path will work no matter where it is moved to assuming the file is synced to the server), however, it doesn't offer great SEO for the URL.

Because Content Staging is involved, there isn't a great solution that's not going to involve some sort of code / data update. I see you have a couple of options:

  1. Update your STAGING server to store fiels in Azure Storage. This shoudl be a different storage account (or maybe just a container) from your PROD server. Configure your site for "Permanent URLs". Reference your media libraries using the /getmedia/ path. After the file / content is sync to the PROD server, you will want to go and update all of the paths to the media to reference the PROD account / container. You might be able to do this with a few SQL scripts if isolated the fields you needed to fix.

  2. Leave your STAGING server using the local file system and direct paths. Once you sync the files / content, go through the same process above of updating the values to the CDN path. This may be a lot tougher because you will have to isolate the paths to identify them, rather just looking for the STAGING Storage name or something.

I was going to say you could not use staging on your media library files, however, this will defeat the purpose of syncing the content so it solves nothing.

The use of the CDN and Staging definitely complicates things and I'm still trying to come up with a good solution, other than what I listed.

0 votesVote for this answer Unmark Correct answer

Recent Answers

Bryan Soltis answered on September 9, 2015 22:58 (last edited on September 9, 2015 23:01)

Hey Joel. It's funny you asked this because I was just working on a blog about that today! I am still testing some stuff, but I can tell you this:

  • You upload a file to media library on the Staging server, it will sync that file to the PROD server.
  • If your PROD server is configured to use Azure Storage, the new media file will be stored in Azure Storage.
  • You upload a file on your Staging server and reference it (in an Editable region or something) and use the "/getmedia/..." path (Permananet URLS), it will sync that exact value to the PROD server. This will allow the PROD server to find the file because the "/getmedia/.." path is still valid because the file has been synced.
  • The PROD server will pull the file from Azure Storage because it created it there when the file was synced.
  • Kentico will not update the URL to be the CDN Path because to the PROD server, it's just content being synced over. The STAGING server would have to be updated to use the CDN path when the image is referenced in order for the value to be carried over.

  • Bryan

0 votesVote for this answer Mark as a Correct answer

Joel Dahlin answered on September 9, 2015 23:10 (last edited on September 9, 2015 23:29)

Hey Bryan, thanks for the response.

If I understand correctly, I just use the CDN/Blog storage in PROD. In staging I should be using local disk? Also, any references to for example an image should be using the permanent url?

I think that solves most, however permanent urls do require a db lookup hurting performance. Also, friendly file names will be lost as well (SEO).

Am I right on all this?

** I misread, CDN needs to be configured in both environments pointing to PROD if I want to use that.

Thanks, Joel

0 votesVote for this answer Mark as a Correct answer

Chidozie Bright answered on February 2, 2017 18:53 (last edited on February 2, 2017 18:55)

I know this is an old post but perhaps you can answer this question. We have a set up where there are 3 environments all set up according to Kentico documentation for deployment to Azure with Media Libraries and blob storage. We have a local environment, Staging and Production. When the project is ready for launch we want the CDN to be used to serve up images, etc. But for staging and local we were just using Media Libraries and Blob Storage. We've set up the CDN for the production site but when testing this out, the CDN address is not being used (still seeing '/getmedia/...'). If I'm reading your post correctly we need to set up separate CDNs for each environment. Is that the case?

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.