Skip to main content

Devops

Keep your environments in sync with Episerver DXP!

Gears

While iterating on projects it’s always a good idea to keep your lower environments in sync with the latest content and imagery from your production environment.  In some platforms this is a significant effort, but with Episerver DXP it can be easily automated!

Eric Markson from Perficient recently blogged about how to automate the orchestration of Episerver DXP.  Following in his footsteps, I’ve been able to successfully synchronize my Pre-production and Integration environments with production content and images in an automated fashion.  The process is quite simple.

First, we need to use the PromoteToEnvironment.ps1 script which you can fork or clone from here: https://github.com/ericmarkson/EpiCloud-Scripts.  If you want to learn more about this script, follow along on Eric’s blogs.  The jist of it though, is that we can call this with source and target environments with a number of switches.

In general, this script would normally be used to promote changes up.  Integration -> Pre-prod, Pre-prod -> Prod, etc.  The API also allows you to select what types of elements to promote: Code, Database, Blobs, etc.  What many people (including myself) don’t initially realize is: You can promote downward and skip the code.

This means that we can create two sets of automation:

  1. One to promote Code from Integration -> Pre-production -> Production (our standard Continuous Delivery style pipeline)
  2. A secondary to promote Database and blobs from Production -> Pre-production -> Integration

Setting this up is also incredibly simple within a tool like Azure Devops:

Content Migration Automation 1

In the above screenshot, I’ve created a release pipeline tied back to my application’s code base.  The application has the PromoteToEnvironment.ps1 script checked into source, which is used as an artifact on this release.  I schedule this release to run over the weekend, but really it could be executed every night if you wish.  For us, it takes about 30 minutes to execute per environment.

The job itself is quite simple as well:

Content Migration 2

 

The parameters here are also quite simple:

  • ClientKey, ClientSecret, and ProjectID: all of these are obtainable within the DXP portal.  Ours are set as variables attached to this release.
  • SourceEnvironment and TargetEnvironment: where you want to migrate to.  In this case we’re going from production to pre-production.
  • IncludeCode, IncludeBlobs, and IncludeDb: this is where the magic happens.  I don’t want to pull code from prod, because we’re using pre-production to test the latest code.  Instead, we want to pull the database and blobs, so we set these flags to 1.
  • SourceApp: for us, we’re migrating the CMS.  You could also migrate other parts of Epi as needed.

I personally thought this was really cool (borderline amazing) after working in other platforms where this type of task is nearly impossible.  It goes to show just how powerful the Episerver DXP platform really is.  Enjoy!

Thoughts on “Keep your environments in sync with Episerver DXP!”

  1. Hi Dylan,

    This article is quite interesting!, actually me and some coworkers are trying to develop and implement something like this, since we are figuring out how we can be able to automate certain processes (specifically to do the downward of DB and BLOBS from Prod to Preprod and also to Inte).

    There are a lot of things that are not clear for me regarding how to do and set the whole process…
    If you might be kind to support me with more info about how to create and configure the Pipeline in Azure DevOps, I will appreciated it so much.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Dylan McCurry, Solutions Architect

I am a certified Sitecore developer, code monkey, and general nerd. I hopped into the .NET space 10 years ago to work on enterprise-class applications and never looked back. I love building things—everything from from Legos to software that solves real problems. Did I mention I love video games?

More from this Author

Categories
Follow Us
TwitterLinkedinFacebookYoutubeInstagram