Tag Archives: BCContainers

Connect to Business Central Container using VS Code

In the last article, we created our first Business Central Container for development. But how to use it within the VS Code environment?

There is nothing special about the configuration. Just use values from message gained once the container was created.

Use a value of “Dev. Server” as a value of “server” property in launch.json and in the same way use value of “Dev. ServerInstance” as a value of “serverInstance”.

     "version": "0.2.0",
     "configurations": [
             "name": "My Container (Kepty-Demo)",
             "request": "launch",
             "type": "al",
             "environmentType": "OnPrem",
             "server": "http://Kepty-Demo",
             "serverInstance": "BC",
             "authentication": "UserPassword",

Access Business Central database running in a container from the Microsoft SQL Server Management Studio

Whether your instances are running directly on the server or in containers, it is sometimes necessary to access a database directly from the SQL Server Management Studio. When you have everything installed on your device, it is usually straightforward – you have the database on SQL Express Server installed together with the Business Central, or the database is deployed on your existing SQL Server.

However, when you use BC Containers (with the standard setup – everything running inside the container, even database), it could be unclear how to access the database.

The first thing to know is that the database can be accessed like any other database, without any special setup.

So, how we can access the database? The most important things to know are that the database is accessible only from the computer where the container is running, and that database server name is the same as the name of your container. The same is also your user name and password (as you used to create a BC container/instance).

Access database hosted in BC container from Microsoft SQL Server Management Studio

Start SQL Server Management Studio on the computer where the container is running, set the server name to the same value as your container name and use your own credentials that you set for the container and that’s it!

Starting with Container-Based Development using Dockers

Microsoft Dynamics 365 Business Central offers images for container-based development. Creating a new development environment using this container-based image (with Docker) is especially quick and easy.

Install Docker

The first thing that must be done is installing Docker. Docker. The current stable version for Windows could be found directly on docker.com (Windows 10).

Once the Docker is installed (the installation will probably require a restart of the computer), set the docker to use Windows containers (in Taskbar, right-click on the Docker icon and choose “Switch to Windows Containers”. If you already have any Linux containers, they won’t be deleted, but you won’t be able to manage them while you are working with Windows containers.

Create Container

The easiest way how to install container is to use PowerShell module created by Freddy Kristiansen that is available on powershellgallery.com.

This module contains many functions that are prepared directly for using for the Business Central and helps a lot with any task from creating to managing containers.

To start with, open a PowerShell (run as an administrator) and install this module using Install-Module command. Then import the module using Import-Module.

Install-Module -Name navcontainerhelper
Import-Module navcontainerhelper

Once we have the module installed & imported, we can create a new container using New-NavContainer function (see details of how to use this function in Freddy’s article where he introduced all new functions in the NavContainerHelper module).

PS C:\WINDOWS\system32> Measure-Command {
    $artifactUrl = Get-BCArtifactUrl -version 16.4 -select Latest -country w1
    $credential = New-Object pscredential 'Kepty', (ConvertTo-SecureString -String 'TKA@Password' -AsPlainText -Force)
    New-NavContainer `
        -accept_eula `
        -containerName Kepty-Demo `
        -artifactUrl $artifactUrl `
        -Credential $credential `
        -auth UserPassword `
        -updateHosts `
        -imagename 16-4-w1

Using this script, we create a new container with the name “Kepty-Demo”, credentials “Kepty” / “TKA@Password” with an image of Business Central 16.4 W1.

Once the script finishes (it may take time, sometimes up to 45 minutes till the image is downloaded and container created).

NavContainerHelper is version
NavContainerHelper is running as administrator
Host is Microsoft Windows 10 Education - 1909
Docker Client Version is 19.03.13
Docker Server Version is 19.03.13
ArtifactUrl and ImageName specified
Fetching all docker images
Downloading application artifact /sandbox/16.4.14693.19714/w1
Downloading C:\Users\Kepty\AppData\Local\Temp\acc7c156-c5c5-46ac-b407-d987704aa4bb.zip
Unpacking application artifact to tmp folder using Expand-Archive
Image 16-4-W1:sandbox-16.4.14693.19714-w1 doesn't exist
Building image 16-4-W1:sandbox-16.4.14693.19714-w1 based on https://bcartifacts.azureedge.net/sandbox/16.4.14693.19714/w1
Pulling latest image mcr.microsoft.com/dynamicsnav:10.0.18363.1198-generic
10.0.18363.1198-generic: Pulling from dynamicsnav

9038b92872bc: Pulling fs layer
d2c27142114e: Pulling fs layer
4e34d77e7c33: Waiting
d2c27142114e: Waiting
ebf009e1d015: Verifying Checksum
ebf009e1d015: Download complete
708d38bb8af6: Verifying Checksum
708d38bb8af6: Download complete
9038b92872bc: Pull complete
d2c27142114e: Pull complete
Digest: sha256:6c7974113fc53b0eda6db752409b9bebfd1c7dce8327bcf6fe0f917a5104d50f
Status: Downloaded newer image for mcr.microsoft.com/dynamicsnav:10.0.18363.1198-generic
Generic Tag:
Container OS Version: 10.0.18363.1198 (1909)
Host OS Version: 10.0.18363.1198 (1909)
Downloading platform artifact /sandbox/16.4.14693.19714/platform
Downloading C:\Users\Kepty\AppData\Local\Temp\c57ebf7f-be77-488b-a31c-5647f9933ee8.zip
Unpacking platform artifact to tmp folder using Expand-Archive
Downloading Prerequisite Components
Downloading c:\bcartifacts.cache\sandbox\16.4.14693.19714\platform\Prerequisite Components\Open XML SDK 2.5 for Microsoft Office\OpenXMLSDKv25.msi
Downloading c:\bcartifacts.cache\sandbox\16.4.14693.19714\platform\Prerequisite Components\IIS URL Rewrite Module\rewrite_2.0_rtw_x64.msi
Downloading c:\bcartifacts.cache\sandbox\16.4.14693.19714\platform\Prerequisite Components\DotNetCore\DotNetCore.1.0.4_1.1.1-WindowsHosting.exe
Copying Platform Artifacts
Copying Database
Copying Licensefile
Copying Extensions
Building image took 492 seconds
Using image 16-4-w1:sandbox-16.4.14693.19714-w1
Creating Container Kepty-Demo
Version: 16.4.14693.19714-W1
Style: sandbox
Platform: 16.0.14648.19648
Generic Tag:
Container OS Version: 10.0.18363.1198 (1909)
Host OS Version: 10.0.18363.1198 (1909)
Using locale en-US
Using process isolation
Disabling the standard eventlog dump to container log every 2 seconds (use -dumpEventLog to enable)
Files in C:\ProgramData\NavContainerHelper\Extensions\Kepty-Demo\my:
- AdditionalOutput.ps1
- MainLoop.ps1
- SetupVariables.ps1
- updatehosts.ps1
Creating container Kepty-Demo from image 16-4-w1:sandbox-16.4.14693.19714-w1
Waiting for container Kepty-Demo to be ready
Setting host.docker.internal to in container hosts file (copy from host hosts file)
Setting gateway.docker.internal to in container hosts file (copy from host hosts file)
Setting kubernetes.docker.internal to in container hosts file (copy from host hosts file)
Setting host.containerhelper.internal to in container hosts file
Starting Container
Hostname is Kepty-Demo
PublicDnsName is Kepty-Demo
WARNING: DNS resolution not working from within the container.
Using NavUserPassword Authentication
Starting Local SQL Server
Starting Internet Information Server
Creating Self Signed Certificate
Self Signed Certificate Thumbprint 7EFE7BCF953F86A54D82DD84DF6790C5093F39AD
Modifying Service Tier Config File with Instance Specific Settings
Starting Service Tier
Registering event sources
Creating DotNetCore Web Server Instance
Enabling Financials User Experience
Creating http download site
Setting SA Password and enabling SA
Creating Kepty as SQL User and add to sysadmin
Creating SUPER user
WARNING: The password that you entered does not meet the minimum requirements. 
It should be at least 8 characters long and contain at least one uppercase 
letter, one lowercase letter, and one number.
Container IP Address:
Container Hostname  : Kepty-Demo
Container Dns Name  : Kepty-Demo
Web Client          : http://Kepty-Demo/BC/
Dev. Server         : http://Kepty-Demo
Dev. ServerInstance : BC
Setting Kepty-Demo to in host hosts file


Container Total Physical Memory is 15.9Gb
Container Free Physical Memory is 5.6Gb

Initialization took 145 seconds
Ready for connections!
Reading CustomSettings.config from Kepty-Demo
Creating Desktop Shortcuts for Kepty-Demo
Container Kepty-Demo successfully created

Days              : 0
Hours             : 0
Minutes           : 11
Seconds           : 2
Milliseconds      : 578
Ticks             : 6625789612
TotalDays         : 0,00766873797685185
TotalHours        : 0,184049711444444
TotalMinutes      : 11,0429826866667
TotalSeconds      : 662,5789612
TotalMilliseconds : 662578,9612

A that’s all! The container is created and is accessible through a link at the end of the report (for the example, the link to the web client is http://Kepty-Demo/BC)

If you want to find out more about the module “NavContainerHelper” see Freddy’s GitHub.