Automate environment backup as part of solution deployments using Build Tools

18th July 2023

Ever deployed a solution to an environment manually or using build tools and caused a bit of a catastrophe in doing so with changes the deployment makes? Perhaps, you deleted a column of data or table in development somehow, and deployed those changes resulting in a loss of your data? Well I’m here with a post to resolve those scenarios!

In the latest part of my wider series on the Power Platform developer tools we’ve been talking about using the Power Platform Build Tools to automate various tasks around application lifecycle management. In this post, we’re going to make the addition to this part of the series of looking at some build tools tasks around environment lifecycle management. I’ll be showing you how to automate environment backups as part of a release pipeline as the very first step before making an environment change by completing a deployment.

Release pipeline

So first let’s take a look at a release pipeline I’ve got. In my last three posts we looked at the following…

We’re going to take a look at the release pipeline I created for the solution in the posts above, and add an environment backup into this release pipeline as the first task to be completed.

So here is my release pipeline with two stages in it for me to deploy to two different environments.

I’m going to step into the tasks for the build stage first, and then I’ll apply the same changes to the rest of the stages later. For now lets look at the changes I’ll need to make to my build environment.

At the moment my stage this is what I’m working with. Simply just a task to import my solution to the environment which utilises a deployment settings file.

I’m now going to add a new task in, in-between the Power Platform Tool Installer task, and the Import Solution task. I need to always add any Power Platform Build Tools tasks in following the tool installer task, and the task I want to do must happen before I make any changes to the environment by importing a solution.

So now I’m going to add the Power Platform Backup Environment task in, after the tool installer task.

So I’ve now added in my task, all I need to do here is set the authentication type to service principal and then utilise the service connection relevant to the environment this stage does a deployment to.

Now I’m going to save my release pipeline and give it a run, to see what happens!

So, to start with, we have a successful pipeline run!

Not only that, if I take a look at my environment in the Power Platform admin center, I’ve got my backup there just in case something didn’t go quite right with my deployment 🙂

Now you have a backup taken just before deployments for any cases where a deployment didn’t go completely right! What an easy way to roll back 💖🚀

Upcoming content

So! We’re not done with this content yet. I’ve still got more posts coming on the Power Platform Build Tools and much more as part of this wider series on the Power Platform Developer Tools!

Make sure you’re subscribed so you don’t miss a thing, and instead, my posts get delivered to your inbox on a daily basis, throughout this year as part of my challenge to complete #365PostsIn365Days! 📩

Posted in Power Platform Dev Tools
  • Zeeshan Ghause

    Hi Lewis
    thanks for your assistance can you please write blog on how to perform testing in Azure devops for crm and power platform. Specially a roll back in sense of unmanaged solution deployment failure

    9:41 pm 18th July 2023 Reply
    • Hi Zeeshan. I’ll take a look at writing a post which covers using test cases and how to properly plan testing in DevOps which links up to releases. With regards to a rollback, this is a little difficult as you have to always increase the solution version number when importing. You could take an older build artifact or older version of a solution from your source control system/repo and manipulate it to have a higher version number then import, or using the functionality in this pipeline take advantage of the environment backup here but accept this will result in loss of data created since the backup timestamp. Hope this helps 🙂

      10:05 pm 26th July 2023 Reply

Leave a Reply

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

This will close in 0 seconds