Hi all,
Previous Post in this series are -
In This post we will move to next steps to Creating Multiple Tenants From Customer Database.
Till Now, We have separated the Application, Data Part, Configured Service Tier & Mount The Application & Customer Data in Service Tier.
STEPS -
5. Importing Modules.
For Creating Multiple Tenants we require Some Modules which can be found in NAV 2013 R2 DVD Inside Folder WindowsPowerShellScripts - Multitenancy
Copy the Multitenancy Folder in D Drive, till we complete the Process.
Delete the content of PowerShell and Paste Below Commands.
------------------------------------------------------------------------------------
#Import Module
Import-Module 'D:\Multitenancy\NAVMultitenancySamples.psm1' -Verbose
------------------------------------------------------------------------------------
You need to change these things -
- Path for Modules.
Run the Command, the Modules are imported.
6. Creating Multiple Tenants.
Tasks need to Perform –
- Move a Company or set of Companies to a new Tenant from Default tenant.
- Dismount Tenant if Multiple Company.
- Remove the Company or set of Companies from Default Tenant once Moved.
- Mount Tenant.
In My Case i want this set of Tenants as shown below-
Delete the content of PowerShell and Paste Below Commands and execute.
------------------------------------------------------------------------------------
#Move Company 1 Data To IT Tenant
HowTo-MoveCompanyToTenant -ServerInstance ‘MultiTenent’ -DatabaseServer 'localhost\NAVDEMO' -FromDatabase 'ABC Company Database NAV 2013 R2' -CompanyName 'IT Services - Hardware' -OldTenantName 'default' -NewTenantName 'IT' -ServiceAccount 'NT AUTHORITY\NETWORK SERVICE' -RemoveCompanyWhenMoved
Dismount-NAVTenant MultiTenent -Tenant IT -Force
#Move Company 2 Data To IT Tanent
HowTo-MoveCompanyToTenant -ServerInstance ‘MultiTenent’ -DatabaseServer 'localhost\NAVDEMO' -FromDatabase 'ABC Company Database NAV 2013 R2' -CompanyName 'IT Services - Software' -OldTenantName 'default' -NewTenantName 'IT' -ServiceAccount 'NT AUTHORITY\NETWORK SERVICE' -RemoveCompanyWhenMoved
------------------------------------------------------------------------------------
You need to change these things -
- Server Instance, Database Name, Old Tenant Name, New Tenant Name & Company Name.
During Execution you might end up with a warning that tenant IT Already exist, Do you want to continue. Just click Yes.
Run the command.
Delete the content of Powershell and Paste Below Commands and execute.
------------------------------------------------------------------------------------
#Move Data To FB Tanent
HowTo-MoveCompanyToTenant -ServerInstance ‘MultiTenent’ -DatabaseServer 'localhost\NAVDEMO' -FromDatabase 'ABC Company Database NAV 2013 R2' -CompanyName 'Clothing' -OldTenantName 'default' -NewTenantName 'FB' -ServiceAccount 'NT AUTHORITY\NETWORK SERVICE' -RemoveCompanyWhenMoved
Dismount-NAVTenant MultiTenent -Tenant FB -Force
#Move Data To FB Tanent
HowTo-MoveCompanyToTenant -ServerInstance ‘MultiTenent’ -DatabaseServer 'localhost\NAVDEMO' -FromDatabase 'ABC Company Database NAV 2013 R2' -CompanyName 'Food-Beverages' -OldTenantName 'default' -NewTenantName 'FB' -ServiceAccount 'NT AUTHORITY\NETWORK SERVICE' -RemoveCompanyWhenMoved
You need to change these things -
- Server Instance, Database Name, Old Tenant Name, New Tenant Name & Company Name.
Run the command.
Let's Check the SQL Server.
So What happened when we executed the above two commands is, it took the companies from default database and moved them to respective tenants as per the command. For Two Tenants the two databases have been created in SQL.
Let's See the Service tier.
So as you can see we have multiple tenants in Service Tier.
Now's let’s check the windows client.
As you can see, each tenant have respective company as we wanted.
Commands used in this post can be found in My Sky Drive Folder.
File Name - Command 5 - Split Application Part & Customer Data Part.ps1
I don’t want to have this Default tenant so In the Next Post of this series we will see how we can remove the default tenant by moving the company and deleting this tenant.
Stay Tuned.
Regards,
By Saurav Dhyani
Comments
Post a Comment