A lot has been written about how to migrate from Single Tenancy to Multi-Tenancy. Video’s have been created, blogs have been written, Sessions have been given.. . The question that I always get – is “what about the other way around?”. So, how do I migrate back to a Single Tenant Environment?
I’ve spend some time to sort this out for you. And it wasn’t that difficult. In fact, it’s easy and logical. Just one trick to realize: when you export an app, it’s not only possible to export it to a new database, but it’s also possible to “export” it to an existing database.
So basically, migrating a Tenant to a Single Tenant database, means:
- Dismounting the Tenant
- “Export” the app to that Tenant database
- Start a server in Single Tenancy mode to that database
Or .. when you want to move a complete Multi Tenant environment to a Single Tenancy Environment, it’s quite the same:
- Move all companies (or the ones you want to convert to a single tenancy database) from all tenants to one (new) tenant
- Do the exact same as above with this tenant
As I said, the real trick is the export of the application to the tenant that you want to migrate.. . I wrote a script for that:
function HowTo-ConvertTenantToSingleTenantDb
{
[CmdletBinding()]
param (
[parameter(Mandatory=$true)]
[String]$SourceServerInstance,
[parameter(Mandatory=$true)]
[String]$SourceTenantId
)
PROCESS
{
$SourceTenant = Get-NAVTenant -ServerInstance $SourceServerInstance -Tenant $SourceTenantId
$SourceApp = Get-NAVApplication -ServerInstance $SourceServerInstance
Dismount-NAVTenant -ServerInstance $SourceServerInstance -Tenant $SourceTenantId -Force
Export-NAVApplication -DatabaseServer $SourceApp.’Database server’ -DatabaseName $SourceApp.’Database name’ -DestinationDatabaseName $SourceTenant.DatabaseName -Force
}
}
This script is creating a function that needs two parameters: the SourceServerInstance and the SourceTenantID. And then, it will create a Single Tenant Database of that tenant. You can use this “function” in a script like this:
$SourceServerInstance = “DynamicsNAV71″
$SourceTenantId = “prscompany”
$SourceTenant = Get-NAVTenant -ServerInstance $SourceServerInstance -Tenant $SourceTenantId -ErrorAction Stop
HowTo-ConvertTenantToSingleTenantDb -SourceServerInstance $SourceServerInstance -SourceTenantId $SourceTenantId -ErrorAction Stop -verbose
$DestinationServerInstance = “NewSingleTenant”
Remove-NAVServerInstance -ServerInstance $DestinationServerInstance -Force
New-NAVServerInstance -ServerInstance $DestinationServerInstance -ManagementServicesPort 8045 -ClientServicesPort 8046 -SOAPServicesPort 8047 -ODataServicesPort 8048 -DatabaseServer $SourceTenant.DatabaseServer -DatabaseName $SourceTenant.DatabaseName -Force
Set-NAVServerInstance -ServerInstance $DestinationServerInstance -stop
Set-NAVServerConfiguration -ServerInstance $DestinationServerInstance -KeyName MultiTenant -KeyValue “false”
Set-NAVServerInstance -ServerInstance $DestinationServerInstance -start
The script above is going to convert a tenant to a Single Tenancy database, and going to set up a new (Single Tenant) ServerInstance for that database.. .
Enjoy!