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:
- One to promote Code from Integration -> Pre-production -> Production (our standard Continuous Delivery style pipeline)
- A secondary to promote Database and blobs from Production -> Pre-production -> Integration
Choosing a Global Software Development Partner to Accelerate Your Digital Strategy
To be successful and outpace the competition, you need a software development partner that excels in exactly the type of digital projects you are now faced with accelerating, and in the most cost effective and optimized way possible.
Setting this up is also incredibly simple within a tool like Azure Devops:
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:
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!