The goal of this post is to demo from start to finish the automated build and test of an AL solution for Microsoft Dynamics 365 Business Central.
Setup and configure the build machine
We will create our build machine from a standard Windows 2016 template in Azure.

Docker containers and container images will take a lot of disk space. The data are stored in %ProgramData%\docker

It if obvious that we will not be able to store the lot on the system SSD system drive. To solve this I create an 1TB HDD disk in Azure.


After starting the Azure VM and opening the Server Manager to look at the File and Storage Service we can see the new empty disk that need configuration.

Right click the new drive to create a new volume.

And assign the drive letter

Next go to Add roles and features to add the Containers feature. More information can be found here. We also need to add ‘.NET Framework 3.5 Features’.

I also like to make sure that all Microsoft updates have been installed.
Now I start PowerShell ISE as Administrator.
As Windows Servers are usually configured in a way that prohibits downloads I like to continue the installation task in PowerShell.
To enable all the scripts to be executes we need to change the execution policy for PowerShell scripts. Executing
Set-ExecutionPolicy -ExecutionPolicy Unrestricted
will take care of that. 
Confirm with Yes to all.
To make sure that all the following download functions will execute successfully we need to change the TLS configuration with another PowerShell command.
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Let’s download Visual Studio Code! Use the following PowerShell command
Invoke-WebRequest -Uri https://go.microsoft.com/fwlink/?Linkid=852157 -OutFile "${env:USERPROFILE}\Desktop\VSCodeInstallation.exe"
to download the installation file to your desktop. Start the installation. During installation I like to select all available additional tasks.

We also need to download GIT. Using the following PowerShell command
Invoke-WebRequest -Uri https://github.com/git-for-windows/git/releases/download/v2.18.0.windows.1/Git-2.18.0-64-bit.exe -OutFile "${env:USERPROFILE}\Desktop\GITInstallation.exe"
will download the latest version at the time of this blog post. The only thing I change from default during GIT setup is the default editor. I like to use Visual Studio Code.

Go ahead and start Visual Studio Code as Administrator.

Add the AdvaniaGIT extension to Visual Studio Code

Install AdvaniaGIT PowerShell Scripts! We access the commands in Visual Studio Code by pressing Ctrl+Shift+P. From there we type to search for the command ‘Advania: Go!’ and the when selected we press enter.

You will get a small notification dialog asking you to switch to the AdvaniaGIT terminal window.

Accept the default path for the installation but select No to the two optional installation options.

We need a development license to work with NAV and Business Central. This license you copy into the ‘C:\AdvaniaGIT\License’ folder. In the ‘GITSettings.json’ file that Visual Studio Code opened during AdvaniaGIT installation we need to point to this license file.

The DockerSettings.json file is also opened during installation and if you have access to the insider builds we need to update that file.
{
"RepositoryPath": "bcinsider.azurecr.io",
"RepositoryUserName": "User Name from Collaborate",
"RepositoryPassword": "Password from Collaborate",
"ClientFolders": []
}
If not make sure to have all setting blank
{
"RepositoryPath": "",
"RepositoryUserName": "",
"RepositoryPassword": "",
"ClientFolders": []
}
Save both these configuration files and restart Visual Studio Code. This restart is required to make sure Visual Studio Code recognizes the AdvaniaGIT PowerShell modules.
Let’s open our first GIT repository. We start by opening the NAV 2018 repository. Repositories must have the setup.json file in the root folder to support the AdvaniaGIT functionality.
I need some installation files from the NAV 2018 DVD and I will start by cloning my GitHub NAV 2018 respository. From GitHub I copy the Url to the repository. In Visual Studio Code I open the commands with Ctrl+Shift+P and execute the command ‘Git: Clone’.

I selected the default folder for the local copy and accepted to open the repository folder. Again with Ctrl+Shift+P I start the NAV Installation.

The download will start. The country version we are downloading does not matter at this point. Every country has the same installation files that we require.

This will download NAV and start the installation. I will just cancel the installation and manually install just what I need.

- Microsoft SQL Server\sqlncli64
- Microsoft SQL Server Management Objects\SQLSysClrTypes
- Microsoft Visual C++ 2013\vcredist_x64
- Microsoft Visual C++ 2013\vcredist_x86
- Microsoft Visual C++ 2017\vcredist_x64
- Microsoft Visual Studio 2010 Tools For Office Redist\vstor_redist
To enable the windows authentication for the build containers we need to save the windows credentials. I am running as user “navlightadmin”. I securely save the password for this user by starting a command (Ctrl+Shift+P) and select to save container credentials.

For all the docker container support I like to use the NAV Container Helper from Microsoft. With another command (Ctrl+Shift+P) I install the container helper to the server.


To complete the docker installation I execute.
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
Install-Module -Name DockerMsftProvider -Force
Install-Package -Name docker -ProviderName DockerMsftProvider -Force
in Visual Studio Code Terminal.
We need to point docker to our data storage drive. Kamil Sacek already pointed this out to us.

I use Visual Studio Code to update the docker configuration. As pointed out here the default docker configuration file can be found at ‘C:\ProgramData\Docker\config\daemon.json’. If this file does not already exist, it can be created. I update the ‘data-root’ configuration.

Now let’s restart the server by typing
Restart-Computer -Force
or manually.
After restart, open Visual Studio Code as Administrator.
Now to verify the installation let’s clone my Business Central repository. Start command (Ctrl+Shift+P) ‘Git: Clone’ and paste in the Url to the repository.

This repository has a setup.json that points to the Business Central Sandbox.

Make sure to have the Integrated Terminal visible and let’s verify the installation by executing a command (Ctrl+Shift+P) ‘Advania: Build NAV Environment’ to build the development environment.

The image download should start…

You should now be able to use the command (Ctrl+Shift+P) ‘Advania: Start Client’, ‘Advania: Start Web Client’, ‘Advania: Start FinSql’ and ‘Advania: Start Debugger’ to verify all the required NAV/BC functionality.

If you are happy with the results you should be able to install the build agent as shown by Soren Klemmensen here.