Automating the Upgrade Process using Sample Windows PowerShell Scripts
You can use Windows PowerShell scripts to help you upgrade to the latest version of Microsoft Dynamics NAV. You can use automation to upgrade a single Microsoft Dynamics NAV database as well as multiple Microsoft Dynamics NAV databases that use the same application. Microsoft Dynamics NAV 2013 R2 provides sample scripts that you can adapt for your deployment architecture.
For an example of how the Microsoft Dynamics NAV sample scripts can help you during the upgrade process, see Walkthrough: Automating the Upgrade Process.
Automating the Data Upgrade
By using Windows PowerShell, you can automate the part of the upgrade process that upgrades data. Also, you can use the same scripts to test your upgrade process before you upgrade production databases.
Also, if you maintain multiple Microsoft Dynamics NAV databases, for example if you support multiple customers with the same Microsoft Dynamics NAV application, you can reduce the time that you spend upgrading each database by using Windows PowerShell scripts. In that case, you can upgrade the application locally, and then use scripts to roll out the upgrade of each database with a short time when each database is not available. You can combine this automated upgrade with a migration to multitenancy if this makes maintenance easier for you.
The Sample Scripts for Data Upgrade
Microsoft Dynamics NAV includes sample scripts that illustrate how you can automate the upgrade of data to the latest version of Microsoft Dynamics NAV. The sample scripts are located in the Upgrade folder under the WindowsPowerShellScripts folder on the Microsoft Dynamics NAV product media. The sample scripts include three HowTo scripts that illustrate how you can create scripts that use the Microsoft Dynamics NAV cmdlets and sample scripts. The following table describes the HowTo scripts.
Illustrates how you can create a script upgrades a database from the earlier version of Microsoft Dynamics NAV to the current version of Microsoft Dynamics NAV through a pipeline of upgrade steps.
Illustrates how to set up an upgrade pipeline that consists of three Microsoft Dynamics NAV Server instances. A specific version of the application is mounted against each Microsoft Dynamics NAV Server instance.
Illustrates how you can create a script that removes the different components that are used during the data upgrade, such as the Microsoft Dynamics NAV Server instances and application databases.
The Upgrade folder also contains the Set-PartnerSettings.ps1 where you can specify values for the input parameters that the HowTo scripts require, such as the database that you want to upgrade.
The Example.ps1 script reads the upgrade parameters from the Set-PartnerSettings.ps1 script and then calls the HowTo scripts sequentially. This illustrates how you can combine the sample scripts in the right order of sequence.
To run the sample scripts for the data upgrade of a Microsoft Dynamics NAV database, you must prepare three application databases with the application objects as described in the following table.
|Sample database name||Description|
Contains the application tables from the converted Microsoft Dynamics NAV 2013 database and the Upgrade Toolkit Step 1 objects.
This version is mounted against the Microsoft Dynamics NAV Server instance that is used in step 4.
Contains the application tables from the Microsoft Dynamics NAV 2013 R2 database with your customizations, the Upgrade Toolkit Step 1 objects, and the Upgrade Toolkit Step 2 objects.
This version is mounted against the Microsoft Dynamics NAV Server instance that is used in step 5.
Contains the application tables from the Microsoft Dynamics NAV 2013 R2 database with your customizations.
This application database must contain the configuration data for permissions, permission sets, web services and client control add-ins that the fully upgraded database must contain.
This version is mounted against the Microsoft Dynamics NAV Server instance that is used in step 6.
The Example1.ps1 script performs the following main steps:
Loads the settings from the Set-PartnerSettings.ps1 file, and then creates the upgrade pipeline by deploying three Microsoft Dynamics NAV Server instances and mounting the relevant application databases against each instance.
If a customer license is found, the license file is copied to the folder that is specified in the Set-PartnerSettings.ps1 script. During the remaining steps of the data upgrade process, the partner license is used.
Converts the database to Microsoft Dynamics NAV 2013 R2.
Removes the application objects from the database.
This is required so that the database can be mounted against a Microsoft Dynamics NAV Server instance that has an application database mounted as well.
Mounts the database against the first Microsoft Dynamics NAV Server instance, runs Upgrade Toolkit Step 1 for all companies, and then dismounts the database.
Mounts the database against the second Microsoft Dynamics NAV Server instance and runs Upgrade Toolkit Step 2 for all companies. If a RapidStart package is specified in the Set-PartnerSettings.ps1 script, this package is applied to all companies. Then, the database is dismounted.
Mounts the database against the third Microsoft Dynamics NAV Server instance, removes the Upgrade Toolkit objects, and then dismounts the database.
The Upgrade Toolkit objects are removed when the database is mounted against the Microsoft Dynamics NAV Server instance in synchronization mode.
Removes the Upgrade Toolkit objects from the application database that was used by the third Microsoft Dynamics NAV Server instance. Then, the application tables are extracted from the application database and imported into the now fully upgraded business database.
The sample script uses the functionality of a multitenant deployment architecture to separate application and business data into different databases. But the script reintroduces the application tables in the business database so that you can use the database in a single-tenant deployment.
Preparing the Upgrade Pipeline
We recommend that you upgrade the application in a dedicated application database because it makes it easier to roll out the upgrade across multiple databases. Even if you are not going to migrate to multitenancy, you can handle the manual steps that are needed in the upgrade process in the separate application database. Then, you import the upgraded application into the upgraded databases. This reduces the time that each database is unavailable to your customers.
To run the sample script for upgrading a Microsoft Dynamics NAV database, you must prepare the three application databases that are described above.
For more information, see Converting a Microsoft Dynamics NAV 2013 Database.
The following list describes the main steps in upgrading the application:
Merge your customizations from the earlier version of Microsoft Dynamics NAV with the application from the current version. For more information, see Upgrading the Application Code.
Update your existing roles and permissions based on the changes in the application.
Import the new Microsoft Dynamics NAV 2013 R2 client control add-ins.
Import the Upgrade Toolkit objects.
Export the application tables to a dedicated application database. For more information, see How to: Export the Application Tables to a Dedicated Database.
The result of the application upgrade is a database that you use as the application database in the upgrade process.
When you have prepared the three versions of the application, you can set up the upgrade pipeline. You must set up three Microsoft Dynamics NAV Server instances and mount the relevant application and business databases against them as illustrated in the following diagram.
For an example of to set up an upgrade pipeline, see Walkthrough: Automating the Upgrade Process.