Option 3 – Sandbox in a local container
If you prefer to have your development sandbox in a container on your local machine, you must have Docker installed and working on your machine. It should be configured to run Windows containers, rather than the default Linux ones. Once you have that, you can perform the following steps:
- Download CreateSandboxContainer.ps1 from the GitHub repository.
- Run PowerShell ISE as an administrator and open CreateSandboxContainer.ps1.
Let's look at what the code does. The first line in the script installs NavContainerHelper, which is a PowerShell module that contains an entire toolbox of commands for interacting with Business Central containers:
$install-module navcontainerhelper -force
- We have the end-user license agreement. You must manually accept the agreement by setting $accept_eula = $true:
# set to $true to accept the eula (https://go.microsoft.com/fwlink/?linkid=861843)
$accept_eula = $false
- You need to assign your sandbox container a name:
# set the name of your container (must be 15 characters or less)
$containername = ''
- You need to define which Docker image will be used for the sandbox container. Refer to the link in the script for information on which images are available, as follows:
# set image to use to create container (see here for available images: https://hub.docker.com/_/microsoft-businesscentral-sandbox)
$bcdockerimage = 'mcr.microsoft.com/businesscentral/sandbox:us'
- Set your login credentials. The script will configure the container to be based on a user and password login, so here is where you can define what the username and password will be:
# the user you use to login to the Business Central client (is a SUPER user)
$userName = "admin"
$password = ConvertTo-SecureString -String "Pass@word1" -AsPlainText -Force
If you have a Business Central license, you can upload it to an online storage account and access it with a secure URL. You can put the URL in the script, as follows:
# set the secure URL to your Business Central license file (leave blank to use the demo license)
$licenseFileUri = ''
The rest of the script is where the magic happens. First, the username and password that you defined will be converted into PowerShell credential objects, and then the New-NavContainer command does all the heavy lifting to create your sandbox:
$credential = New-Object -TypeName "System.Management.Automation.PSCredential" -ArgumentList $userName, $password
New-NavContainer -accept_eula:$accept_eula `
-containername $containername `
-auth UserPassword `
-Credential $credential `
-licenseFile $licenseFileUri `
-includeCSide `
-alwaysPull `
-doNotExportObjectsToText `
-usessl:$false `
-updateHosts `
-assignPremiumPlan `
-shortcuts Desktop `
-imageName $bcdockerimage `
-useBestContainerOS
- At this point, if you've filled in all the configuration in the script, you can run it by pressing F5. Then, sit back and relax while your container is created. The first thing that will happen is that the Docker image will be downloaded to your machine. This is the longest part of the process because the files are being downloaded, unpacked, and verified. A typical image will be around 10 - 20 GB.
Once that is finished, the container will be created and should be ready in under 10 minutes.
Do not close the PowerShell window yet!
- We need to take note of some important information that we're going to need later. In the PowerShell window, look for the following information and save it for later:
- To verify that your machine is working, open your web browser and navigate to the Web Client address that was listed in the PowerShell window (see the preceding example).
- Install the AL Language extension from the Visual Studio Code Marketplace: https://marketplace.visualstudio.com/items?itemName=ms-dynamics-smb.al.