Database upgrade to a new version

Published on 30 October 2023 at 07:00

Introduction

It's been almost a month since Business Central 2023 Release Wave 2 became generally available. The past month has been quite busy due to upgrading our existing clients to the latest product version. As always, this process takes up a significant amount of time. You can find a step-by-step guide on the official website outlining the necessary steps for upgrading your database.

Up until now, I've been manually inputting paths for all the apps that require an upgrade, including both Microsoft and third-party apps. However, I decided to put in some effort to customize a script that reduces hardcoding paths and other parameters, making it easier to reuse this script for future upgrades.

Let's take a closer look at what this is all about.

 

Power shell script

 

At the beginning of the script, you'll find some helper functions.

Following that, you'll come across the section that prepares the existing database for the upgrade, which involves uninstalling and unpublishing all apps in the database.

Next, we come to the part of the script that has always been my biggest challenge. It involves identifying all the apps that Microsoft has added to the new version and manually hardcoding the paths to these apps. However, I've found a workaround by installing Demo 230 and examining the default apps that come with it. After that, I search for all the apps located in the Demo database in the DVD folder and copy them to a separate folder that I'll use later for some kind of "automatic upgrade".

I quickly checked the number of apps, and it's 48. Imagine manually writing the paths for each of those apps 48 times.  :-)

After that, I added an interesting part that speeds up the process of upgrading NavBiz apps (whose number is increasing day by day). I utilized a portion from the CI/CD pipeline to download dependency apps, allowing me to download the apps that need to be upgraded.

The config file is structured in this way.

After that, we move on to the section where parameters are used to specify which database have to be upgraded, the name of the new server instance, the new version, and so on. You might notice that I was so lazy that I even wrote a function for finding available ports, as well as setting the Log On user for the service.

Following that, we reach the "automatic upgrade" stage, where apps are added to the dependency array, and the upgrade process is "forced" in that sequence. After a few steps within the loop, all Microsoft apps should be upgraded.

After that, we come to the optional section where you have the possibility to upgrade third-party apps.

And finally, we reach the concluding part of the script, which involves upgrading control add-ins and creating web server instances.

Optionally, at the end of the script, you can also create windows instances.

Conclusion

 

As you can see, this script can be easily adapted for use with other versions, and my plan is to continue using it for future upgrades with minimal modifications. One important note is that the script is limited to single-tenant databases.

You can download the complete script from the following link.

 

For me, the upgrade now takes about an hour, as opposed to the previous "manual" method, which used to take multiple times longer.


Add comment

Comments

Marek Mengel
7 months ago

Greetings from Estonia. Great Job!

Mohana
2 months ago

Could you please add the steps of creating the Release pipeline or screenshots?