Update Business Central on premise in minutes!

Every month Microsoft releases a Cumulative Update for Business Central and two times per year a new major version is released (“wave 1” in April and “wave 2” in October).

These new versions are automatically installed in the Cloud: customers that use the SaaS version of BC have nothing to do to keep their system up to date.

But for who uses BC on premise the story can be very different…

Why updates are important

For customers: keep the system up to date preserves it from obsolescence. You can use the new functions released by Microsoft and the improved software is more stable. Updating the system is the only way to keep the value of your software investment.

For partners: maybe someone forgot the time when NAV arrived at its end, when was impossible to easly upgrade decadal systems and the customers just as simply was swtiching to another product. Keep the systems up to date is our job. 🧑‍🔧

Prerequistes

If you chose to use BC on premise, you agreed to have the right version of the operating system (Windows Server) and database (SQL Server). This is the “price” to keep the system on your server.

For example, to run Business Central 2023 wave 2 (v23) you need at least:

  • Windows Server 2019
  • SQL Server 2019

Download the Cumulative Update

First of all download the latest cumulative update for the running version. For example, search on Google “business central 2023 wave 2 cumulative update” and you will be redirected here:

https://support.microsoft.com/en-us/topic/released-updates-for-microsoft-dynamics-365-business-central-2023-release-wave-2-7a4f98e8-66b9-4484-9bc1-66c466d8a82d

Open the latest CU knowledge base page, for example the ID of CU 23.5 (released in March, 2024) is 5036474:

https://support.microsoft.com/en-us/topic/update-23-5-for-microsoft-dynamics-365-business-central-on-premises-2023-release-wave-2-application-build-23-5-16757-platform-build-23-0-16502-0fa482a6-878d-4e31-97d4-9c864dbf7d61

The KB shows you a summary of “platform hotfixes” and “application hotfixes” included in the Cumulative Update.

  • PLATFORM is the “executable” of Business Central (the Windows Service); for example an hotfix can concerns a performance issue
  • APPLICATION is the suite of the Microsoft APP (Base Application and so on); for example an hotfix can concerns a new tax regulatory

Search in the KB “How to obtain the Microsoft Dynamics 365 Business Central 2023 Release Wave 2 files” and download the right ZIP file for your localization. For example this is the link for Italian (IT) localization:

Remember to remove the block for downloaded file from the ZIP before extracting the content! Otherwise all executables will be treated as unsecure (and the server will not start).

How to update

The following procedure is an example for automatically update a single server, multi instance, multi web site. It’s one of the common scenario that I find in the customer’s servers.

Be careful! 😅 The scripts should be adapted for your specific installation and integrated by other important steps. For customers: try them first on your development machine. For partners: it’s “fun” to use always the same installation model (directory structures, instance names…) so you can update with few click all your on premise customers.

Here the link of the Microsoft documentation about V23 Cumulative Update installation: Install a version 23 update – Business Central | Microsoft Learn

Step 1

Stop all services and IIS sites.

Step 2

Update the PLATFORM using this Power Shell script “Fast-Upgrade-Service.ps1

$dvd = "C:\Temp\Dynamics.365.BC.16757.IT.DVD"
$upgradeDev = "$dvd\ModernDev\program files\Microsoft Dynamics NAV\230\AL Development Environment"
$upgradeWeb = "$dvd\WebClient\Microsoft Dynamics NAV\230\Web Client"
$upgradeService = "$dvd\ServiceTier\program files\Microsoft Dynamics NAV\230\Service"
$upgradeWebPublish = "$dvd\WebClient\Microsoft Dynamics NAV\230\Web Client\WebPublish"

$targetDev = "C:\Program Files (x86)\Microsoft Dynamics 365 Business Central\230\AL Development Environment"
$targetWeb = "C:\Program Files\Microsoft Dynamics 365 Business Central\230\Web Client"
$targetService = "C:\Program Files\Microsoft Dynamics 365 Business Central\230\Service"
$targetSites = ,"C:\inetpub\wwwroot\BC230"

Copy-Item $upgradeDev\* $targetDev -Recurse -Force
Copy-Item $upgradeWeb\* $targetWeb -Recurse -Force

$serviceConf = Get-Content $targetService\CustomSettings.config
Copy-Item $upgradeService\* $targetService -Recurse -Force	
Set-Content -Path $targetService\CustomSettings.config -Value $serviceConf	

foreach ($ts in $targetSites) {
	$webConf = Get-Content $ts\NavSettings.json
	Copy-Item $upgradeWebPublish\* $ts -Recurse -Force
	Set-Content -Path $ts\NavSettings.json -Value $webConf
}

Step 3

Start the services and update the APPLICATION using this Power Shell script “Fast-Upgrade-App.ps1

$dvd = "C:\Temp\Dynamics.365.BC.16757.IT.DVD"
$mgmtPath = "C:\Program Files\Microsoft Dynamics 365 Business Central\230\Service\Management"
$instance = "BC230"
$apps = "ModernDev\program files\Microsoft Dynamics NAV\230\AL Development Environment\System.app",
		"Applications\system application\source\Microsoft_System Application.app",
		"Applications\BaseApp\Source\Microsoft_Base Application.app",
		"Applications\Application\Source\Microsoft_Application.app"

Import-Module "$mgmtPath\NavAdminTool.ps1"

Write-Host "1) Uninstall all apps"
Write-Host "2) Publish and install new Microsoft apps"
Write-Host "3) Clean up old Microsoft apps"
Write-Host "4) Re-install other apps"
$choice = Read-Host "Enter step number"

$o1 = Get-NAVAppInfo -ServerInstance $instance -TenantSpecificProperties -Tenant default
$o2 = Get-NAVAppInfo -ServerInstance $instance -SymbolsOnly
$oldApps = $o1 + $o2

if ($choice -eq "1")
{
	foreach ($old in $oldApps)
	{
		if ($old.IsInstalled)
		{
			Write-Output "Uninstalling " + $old.Name
			Uninstall-NAVApp -ServerInstance $instance -Name $old.Name -Version $old.Version -Publisher $old.Publisher -Force
		}
	}
}

if ($choice -eq "2")
{
	foreach ($a in $apps)
	{
		$nfo = Get-NAVAppInfo -Path "$dvd\$a"
		
		if ($nfo.Name -eq "System")
		{
			Write-Output "Publishing $($nfo.Name)"
     		Publish-NAVApp -ServerInstance $instance -Path "$dvd\$a" -PackageType SymbolsOnly
		}
		else
		{
			Write-Output "Publishing $($nfo.Name)"
			Publish-NAVApp -ServerInstance $instance -Path "$dvd\$a"
			
			$nfo = Get-NAVAppInfo -ServerInstance $instance -Name $nfo.Name -Publisher $nfo.Publisher -Version $nfo.Version -TenantSpecificProperties -Tenant default
			if ($nfo.Count -eq 0)
			{
				continue
			}
				
			$nfo = $nfo[0]

			if ($nfo.SyncState.ToString() -ne "Synced")
			{
				Write-Output "Syncing $($nfo.Name)"
				Sync-NAVApp -ServerInstance $instance -Name $nfo.Name -Publisher $nfo.Publisher -Version $nfo.Version

				Write-Output "Data upgrading $($nfo.Name)"
				Start-NAVAppDataUpgrade -ServerInstance $instance -Name $nfo.Name -Publisher $nfo.Publisher -Version $nfo.Version
			}
			
			$nfo = Get-NAVAppInfo -ServerInstance $instance -Name $nfo.Name -Publisher $nfo.Publisher -Version $nfo.Version -TenantSpecificProperties -Tenant default
			$nfo = $nfo[0]
			
			if ($nfo.IsInstalled -ne $True)
			{
				Write-Output "Installing $($nfo.Name)"
				Install-NAVApp -ServerInstance $instance -Name $nfo.Name -Version $nfo.Version -Publisher $nfo.Publisher -Force
			}
		}

		if ($nfo.Name -eq "Base Application")
		{
			Write-Output "Setting application version to $($nfo.Version)"
			Set-NAVApplication -ServerInstance $instance -Force -ApplicationVersion $nfo.Version
		}
	}	
}

if ($choice -eq "3")
{
	foreach ($a in $apps)
	{
		$nfo = Get-NAVAppInfo -Path "$dvd\$a"
		
		foreach ($old in $oldApps)
		{
			if (($nfo.Name -eq $old.Name) -and ($nfo.Publisher -eq $old.Publisher) -and ($nfo.Version -gt $old.Version))
			{
				Write-Output "Unpublishing $($nfo.Name)"
				Unpublish-NAVApp -ServerInstance $instance -Name $old.Name -Publisher $old.Publisher -Version $old.Version
			}
		}
	}	
}

if ($choice -eq "4")
{
	foreach ($old in $oldApps)
	{
		if (($old.IsInstalled -ne $True) -and ($old.SyncState -ne $null) -and ($old.SyncState.ToString() -eq "Synced"))
		{
			Write-Output "Installing $($old.Name)"
			Install-NAVApp -ServerInstance $instance -Name $old.Name -Version $old.Version -Publisher $old.Publisher -Force
		}
	}
}

This Power Shell script performs four important actions:

  1. Uninstall all apps
  2. Publish ad install the new Microsoft apps provided in the Cumulative Update (at least System, System Application, Base Application and Application). This task also syncronizes and upgrades the data of the tenant.
  3. Clean up old Microsoft apps unpublishing them
  4. Reinstall all published apps (third party apps, custom apps…)

Step 4

After about 20 minutes 😁 restart services, IIS sites and there you go!

Major updates

Are the above scripts suitable also for major updates? For example, to upgrade from V22 to V23?

Yes, but you need more adaptations and the scenario must be well prepared before. For example it’s better to use generic instance and web site names rather than version specific (PRODUCTION instead of BC230). Moreover you should be even more careful! 😎

Third party apps and addons

This “rapid” upgrade method works well only if you have installed updated apps from your partner. If these apps are not available or the partner is unreachable you have only two chance:

  • Download the source code, if available, and adjust it for the new version
  • Remove these apps and substitute them with more reliable ones

Unfortunately I know several customers stuck on old BC version (14, 15, 16…) because the partner is scared to upgrade its apps. At this time the current version of BC is 23 “2023 wave 2” and in less than a month the new major version 24 will be released and the old version 21 will go in “end of life” (no more support from Microsoft).

Conclusion

The above scripts are only examples that demonstrate that is possible to automate upgrades and minimize costs to keep up to date the system. More frequently you update Business Central, less work is necessary to install the next major release.

If there are reasons to stay on premise, one of the partner missions is to shorten the gap with the Cloud version. To achieve this objective is necessary: standard installation model, script automation and well organization to do the upgrades as quickly as possible.