«

»

Print this Post

NAV 2013 R2 Multi Tenancy: Force Full Sync on All Tenants

The last few months have been crazy. The main reason that my blogging is somewhat minimal is that I’m working on a project .. Quite an interesting one. It’s an on premise, yet multitenant implementation of 204 tenants and growing. Super interesting, because there is lots of communication between the tenants, and still, you get the benefits from having tenants as well. You might think: he’s abusing the Multitenancy concept … but then again … I’d like to think it’s more like “using and enhancing” ;-).

In any way, when developing for a MultiTenant environment like this .. you sometimes face things you’re not really used to in the singletenant-world. Namely, when you want to do a database-table change that is somewhat disruptive (you change a field, delete a field, …), things might get ugly for “some” of the tenants. Sometimes, you just want to force a change in, no matter if you lose data or not.

In the current implementation of the Powershell Commandlets, the only way to do it, is to dismount the tenant, and mount it again, with the “ForceSync”-option. But when you have 204 tenants, you might want to do it somewhat more automagically .. . Together with my colleague, we wrote following script:

[warning]Disclaimer: Please be very careful to use this script, as it might result in dataloss![/warning]

Import-Module ‘C:\Program Files\Microsoft Dynamics NAV\71\service\NavAdminTool.ps1’ | Out-Null

$Instance = Get-NAVServerInstance DynamicsNAV71
$tenants = $Instance | Get-NAVTenant #| Where-Object { $_.id -like ‘FilterOnTenantId’ }
$count = 0
$total = ($tenants | measure).Count

foreach ($tenant in $tenants){
$Instance | Dismount-NAVTenan -Tenant $tenant.id -Force
  $tenant | Mount-NAVTenant -Mode ForceSync
$count = $count+1
  $count.ToString() + ‘ of ‘ + $total.ToString() + ‘: ‘ + $tenant.id + ‘ was remounted’
}

The output will be something like:

1 of 204: 000000001 was remounted
2 of 204: 100001005 was remounted
3 of 204: 100001015 was remounted
4 of 204: 100001007 was remounted
5 of 204: 100001025 was remounted

 Be careful and enjoy!

5.00 avg. rating (96% score) - 1 vote

Permanent link to this article: http://www.waldo.be/2014/07/17/nav-2013-r2-multi-tenancy-force-full-sync-on-all-tenants/

2 pings

  1. Importing objects in a multi tenancy environment | PA

    […] Waldo Blog: NAV 2013 R2 Multi Tenancy: Force Full Sync on All Tenants. […]

Leave a Reply

%d bloggers like this: