Setting Up Multiple Business Central Web Server Instances Using PowerShell

Although you can use the Business Central Setup to install the Business Central Web Server components and create a single web server instance in IIS for client connection, there may be scenarios when you want to set up multiple instances. For example, you could set up a separate Business Central Web Server instance for the different companies of a business. For this scenario, you can use the Business Central Web Server PowerShell cmdlets, which are outlined in the following table.

Cmdlet Description
New-NAVWebServerInstance Creates a new Business Central Web Server instance and binds this instance to a Business Central Server instance.
Set-NAVWebServerInstanceConfiguration Specifies configuration values for a named Business Central Web Server instance.
Get-NAVWebServerInstance Gets the information about the Business Central Web Server instances that are registered on a computer.
Remove-NAVWebServerInstance Removes an existing Business Central Web Server instance.

Get started with the Business Central Web Server cmdlets

The Business Central Web Server cmdlets are contained in the PowerShell script module NAVWebClientManagement.psm1, which is available on the Business Central installation media (DVD).

The module is installed with the Business Central Server or the Business Central Web Server components.

There are different ways to launch this module and start using the cmdlets:

  • If you are working on the computer where the Business Central Server was installed, run the Business Central Administration Shell as an administrator.

    For more information, see Business Central PowerShell Cmdlets.

  • If you installed the Business Central Web Server components, just start Windows PowerShell as an administrator.

  • Otherwise, start Windows PowerShell as an administrator, and use the Import-Module cmdlet to import the NAVWebClientManagement.psm1 file:

    Import-Module -Name [filepath]
    

    For example:

    Import-Module -Name "C:\Program Files\Microsoft Dynamics 365 Business Central\130\Service\NAVWebClientManagement.psm1"
    

    For more information about starting Windows PowerShell, see Starting Windows PowerShell.

Creating Business Central Web Server instances

Get Access to the WebPublish folder

To create a new web server instance, you need access to the WebPublish folder that contains the content files for the Business Central Web Server components.

  • This folder is available on the Business Central installation media (DVD) and has the path "DVD\WebClient\Microsoft Dynamics NAV\13x\Web Client\WebPublish".

  • If you installed the Business Central Web Server components, this folder has the path "C:\Program Files\Microsoft Dynamics 365 Business Central\140\Web Client\WebPublish".

You can use either of these locations or you can copy the folder to more convenient location on your computer or network.

Decide on the site deployment type for the instance

When you create a new Business Central Web Server instance, you can choose to create either a RootSite or SubSite type. Each instance type has a different hierarchical structure in IIS, which influences its configuration and the URLs for the accessing from the Business Central Web client.

RootSite

A RootSite instance is a root-level web site that is complete with content files for serving the Business Central Web client. It is configured with its own set of bindings for accessing the site, such as protocol (http or https) and communication port. The structure in IIS looks like this:

- Sites
  - BusunessCentralWebSite (web site)
    + nn-NN (language versions)
    + www (content)
    navsettings.json
    ...

The Business Central Web client URL for the RootSite instance has the format:

http://[WebserverComputerName]:[port]

For example: http://localhost:8080.

SubSite

A SubSite instance is a web application that is under a container web site. The container web site is configured with a set of bindings, but the site itself has no content files. The content files are contained in the application (SubSite). The SubSite inherits the bindings from the container web site. This is the deployment type that is created when you install Business Central Web Server components in the Setup wizard. Using the New-NAVWebServerInstance cmdlet, you can add multiple SubSite instances in the container web site. The structure in IIS for two instances looks like this in IIS:

- Sites
  - BusunessCentralWebSite (web site)
    - BusinessCentralWebInstance1 (application)
      + nn-NN (language versions)
      + www 
      navsettings.json
      ...
    - BusinessCentralWebInstance2 (application)
      + nn-NN (language versions)
      + www
      navsettings.json
      ...

The Business Central Web client URL of a SubSite instance is generally longer than a RootSite because it also contains the application's alias (or virtual path) for the instance, which you define. The URL for a SubSite instance has the format:

http://[WebserverComputerName]:[port]/[WebServerInstance]

For example: http://localhost:8080/BusinessCentralWebInstance1 and http://localhost:8080/BusinessCentralWebInstance2.

Run the New-NAVWebServerInstance cmdlet

At the command prompt, run the New-NAVWebServerInstance cmdlet. The following are simple examples for creating a RootSite and SubSite deployment type.

RootSite example:

```  
New-NAVWebServerInstance -WebServerInstance MyBCWebsite -Server MyBCServer -ServerInstance MyBCServerInstance -SiteDeploymentType RootSite -WebSitePort 8081 -PublishFolder "C:\Web Client\WebPublish"
```  

SubSite example:

```  
New-NAVWebServerInstance -WebServerInstance MyWebApp -Server MyBCServer -ServerInstance MyBCServerInstance -SiteDeploymentType Subsite -ContainerSiteName MySiteContainer -WebSitePort 8081 -PublishFolder "C:\WebClient\WebPublish"
```  
  • Susbtitute MyBCWebsite with the name that you want to give the web application in IIS for the web server instance. If you are creating a SubSite deployment type, this name will become part of the URL for opening the Business Central Web client application, for example, http://MyWebServer:8081/MyWebApp.

  • Susbtitute MyBCServer to the name of the computer that is running the Business Central Server to which you want to connect.

  • Susbtitute MyBCServerInstance with the name of the Business Central Server instance to use.

  • Substitute MySiteContainer with name of the container web site under which you want to add the instance. If you specify a name that does not exist, then a new container web site will be created, which contains the new web server instance.

  • Susbtitute 8081 with the port number that you want to bind the instance to. If you do not specify a port number, then port 80 is used.

  • Substitute C:\WebClient\WebPublish with the path to your WebPublish folder. By default, the cmdlet looks in the'C:\Program Files\Microsoft Dynamics 365 Business Central\140\Web Client' folder. So if you are working on a computer where the Business Central Web Server components are installed, you do not have to set this parameter.

Note

This command only sets the required parameters of the NAVWebServerInstance cmdlet. The cmdlet has several other parameters that can use to configure the web server instance. For more information about the syntax and parameters, see New-NAVWebServerInstance.

Modifying a Business Central Web Server instance

After you create the web server instance, if you want to change its configuration, you can use the Set-NAVWebServerInstanceConfiguration cmdlet. Or, you can modify the configuration file (navsettings.json) of the instance directly. For more information, see Configuring Web Server Instances.

See Also

Business Central Web Server Overview
Configuring Web Server Instances