Official Microsoft repository for BcContainerHelper, a PowerShell module, which makes it easier to work with Business Central Containers on Docker.
Перейти к файлу
Freddy Kristiansen 480254c917
Support compilerfolder and online environments (#3607)
When specifying BcAuthContext and Environment to Run-AlPipeline,
Run-AlPipeline would always create a filesonly container, disallowing
running on Linux.
This PR fixes this plus some bugs found as a result of this.

- Replace all occurrences of
[System.Runtime.InteropServices.Marshal]::PtrToStringAuto with
[System.Runtime.InteropServices.Marshal]::PtrToStringBSTR as the Auto
function doesn't always do what's expected under Linux (We do not use
the Auto function in AL-Go)
- Ensure correct casing of Newtonsoft.Json.dll for Linux (also not a
problem in AL-Go)
- Always add extensionId (when specified) to Properties section in test
results xml
- Also added two new overrides (PipelineInitialize and PipelineFinalize)
requested by COSMO Consult.
- If environment is specified as a Web Client URL, and BcAuthContext
contains username/password in Run-AlPipeline, then tests will run
against this environment. PublishBcContainerApp and
ImportTestToolkitToBcContainer needs to be overridden for this to work
with full pipeline.
- Add parameter CompilerFolder to Run-TestsInBcContainer and
Import-TestToolkitToBcContainer for running tests using CompilerFolder
bits from the host
- Including caching of appinfos in CompilerFolder cache (to save time
when caching on GitHub Actions)

Running Build AND Test under Linux (using CompilerFolder), using an
online environment as "Service Tier" can be seen here:

https://github.com/BusinessCentralDemos/bingmaps.pte/actions/runs/10313615507

Build and test here takes approx. 3 minutes.

This functionality is needed by COSMO to enable using their Docker Swarm
for running tests in AL-Go.

COSMO is aware that AL-Go moves away from using BcContainerHelper and
will subsequently have to change their integration when this has
happened.

---------

Co-authored-by: freddydk <freddydk@users.noreply.github.com>
2024-08-09 12:18:10 +02:00
.github Remove SAS URLs (#3547) 2024-05-23 10:18:31 +02:00
AL-Go store clientID in the AL-Go Context 2023-05-30 13:01:37 +02:00
AlpacaBcContainer Use new CDN (#3459) 2024-04-04 09:28:54 +02:00
Api add trustServerCertificate if the parameter exists (#3579) 2024-07-06 15:34:38 +02:00
AppHandling Support compilerfolder and online environments (#3607) 2024-08-09 12:18:10 +02:00
AppSource NuGet changes (#3289) 2024-01-08 06:43:49 +01:00
Artifacts Support compilerfolder and online environments (#3607) 2024-08-09 12:18:10 +02:00
Auth generateDependencyArtifact doesn't work when useCompilerFolder is true (#3564) 2024-05-31 23:16:52 +02:00
AzureAD Support compilerfolder and online environments (#3607) 2024-08-09 12:18:10 +02:00
AzureVM Issue #3118 2023-07-17 15:31:55 +02:00
Bacpac Support compilerfolder and online environments (#3607) 2024-08-09 12:18:10 +02:00
CloudBcContainer rename 2023-06-29 07:00:17 +02:00
Common Support compilerfolder and online environments (#3607) 2024-08-09 12:18:10 +02:00
CompanyHandling telemetry 2021-07-06 11:03:31 +02:00
CompilerFolderHandling Support compilerfolder and online environments (#3607) 2024-08-09 12:18:10 +02:00
ConfigPackageHandling Issue #3051 Unable to import .rapidstart file - The property 'Code' cannot be found on this object 2023-05-16 19:58:29 +03:00
ContainerHandling Support compilerfolder and online environments (#3607) 2024-08-09 12:18:10 +02:00
ContainerInfo Support compilerfolder and online environments (#3607) 2024-08-09 12:18:10 +02:00
LinuxTests Run tests (#3238) 2023-12-02 09:57:08 +01:00
Misc regressions (#3524) 2024-04-29 15:40:45 +02:00
NuGet fix appid.value (#3398) 2024-03-08 13:04:09 +01:00
ObjectHandling Support compilerfolder and online environments (#3607) 2024-08-09 12:18:10 +02:00
PackageHandling Support compilerfolder and online environments (#3607) 2024-08-09 12:18:10 +02:00
Saas Support compilerfolder and online environments (#3607) 2024-08-09 12:18:10 +02:00
SymbolHandling Support compilerfolder and online environments (#3607) 2024-08-09 12:18:10 +02:00
TenantHandling Issue3473 (#3505) 2024-04-24 09:04:11 +02:00
Tests test failure (#3549) 2024-05-24 07:42:09 +02:00
UserHandling Support compilerfolder and online environments (#3607) 2024-08-09 12:18:10 +02:00
.gitignore Support 15.x applications folder+test 2019-08-26 07:30:00 +02:00
BC.ALGoHelper.module.json Do not use submodules in BcContainerHelper 2022-12-17 20:11:52 +01:00
BC.ALGoHelper.ps1 add New-ALGoRepo 2023-05-16 10:21:15 +02:00
BC.ALGoHelper.psd1 Do not use submodules in BcContainerHelper 2022-12-17 20:11:52 +01:00
BC.ALGoHelper.psm1 Do not use submodules in BcContainerHelper 2022-12-17 20:11:52 +01:00
BC.AppSourceHelper.module.json Do not use submodules in BcContainerHelper 2022-12-17 20:11:52 +01:00
BC.AppSourceHelper.ps1 Do not use submodules in BcContainerHelper 2022-12-17 20:11:52 +01:00
BC.AppSourceHelper.psd1 Do not use submodules in BcContainerHelper 2022-12-17 20:11:52 +01:00
BC.AppSourceHelper.psm1 Do not use submodules in BcContainerHelper 2022-12-17 20:11:52 +01:00
BC.ArtifactsHelper.module.json Do not use submodules in BcContainerHelper 2022-12-17 20:11:52 +01:00
BC.ArtifactsHelper.ps1 Do not use submodules in BcContainerHelper 2022-12-17 20:11:52 +01:00
BC.ArtifactsHelper.psd1 Do not use submodules in BcContainerHelper 2022-12-17 20:11:52 +01:00
BC.ArtifactsHelper.psm1 Do not use submodules in BcContainerHelper 2022-12-17 20:11:52 +01:00
BC.HelperFunctions.module.json Do not use submodules in BcContainerHelper 2022-12-17 20:11:52 +01:00
BC.HelperFunctions.ps1 Issue #3555 (#3557) 2024-05-28 07:01:37 +02:00
BC.HelperFunctions.psd1 Do not use submodules in BcContainerHelper 2022-12-17 20:11:52 +01:00
BC.HelperFunctions.psm1 Do not use submodules in BcContainerHelper 2022-12-17 20:11:52 +01:00
BC.NuGetHelper.module.json Do not use submodules in BcContainerHelper 2022-12-17 20:11:52 +01:00
BC.NuGetHelper.ps1 GetPackageId (#3309) 2024-01-26 22:35:50 +01:00
BC.NuGetHelper.psd1 GetPackageId (#3309) 2024-01-26 22:35:50 +01:00
BC.NuGetHelper.psm1 feat: Added function Create-SaasUrl 2023-03-30 21:17:33 +02:00
BC.SaasHelper.module.json feat: Added function Create-SaasUrl 2023-03-30 21:17:33 +02:00
BC.SaasHelper.ps1 renames 2023-05-23 09:47:24 +02:00
BC.SaasHelper.psd1 feat: Remove required files 2023-04-05 08:51:18 +02:00
BC.SaasHelper.psm1 feat: Added function Create-SaasUrl 2023-03-30 21:17:33 +02:00
BC.module.json Do not use submodules in BcContainerHelper 2022-12-17 20:11:52 +01:00
BC.psd1 Do not use submodules in BcContainerHelper 2022-12-17 20:11:52 +01:00
BC.psm1 use submodules 2022-12-08 08:29:08 +01:00
BcContainerHelper.module.json compilerFolder 2023-03-14 12:12:11 +01:00
BcContainerHelper.ps1 Do not use submodules in BcContainerHelper 2022-12-17 20:11:52 +01:00
BcContainerHelper.psd1 GetPackageId (#3309) 2024-01-26 22:35:50 +01:00
BcContainerHelper.psm1 do not use winrm if not running (#3520) 2024-04-29 10:15:20 +02:00
CI_CD_Workshop.md Update CI_CD_Workshop.md 2022-04-11 00:23:26 +02:00
CODEOWNERS Uptake new GitHub teams in CODEOWNERS (#3178) 2023-09-29 09:20:54 +02:00
Check-BcContainerHelperPermissions.ps1 PS7 bug + 2 more (#3386) 2024-03-05 10:49:17 +01:00
CreateALGoRepo.ps1 Removal of Insider SAS Token (#3166) 2023-09-27 15:09:36 +02:00
CreateScript.ps1 Fix issue in CopyApps (#3436) 2024-03-26 08:28:15 +01:00
HelperFunctions.ps1 Support compilerfolder and online environments (#3607) 2024-08-09 12:18:10 +02:00
Import-BC.ps1 casing 2022-12-18 07:15:51 +01:00
Import-BcContainerHelper.ps1 casing 2022-12-18 07:11:41 +01:00
InitializeModule.ps1 fix dumps 2023-05-06 07:35:59 +02:00
LICENSE Initial commit 2017-09-26 13:11:09 -07:00
Microsoft.ApplicationInsights.dll dotnetstd20 2022-12-09 16:27:34 +01:00
NavContainerHelper.md Support compilerfolder and online environments (#3607) 2024-08-09 12:18:10 +02:00
README.md Readme.md improved (#3551) 2024-05-26 07:49:21 +02:00
ReleaseNotes.txt Support compilerfolder and online environments (#3607) 2024-08-09 12:18:10 +02:00
SECURITY.md Microsoft mandatory file 2023-06-02 06:31:12 +00:00
SaaSHelperFunctions.ps1 corrected export-modulemember 2023-05-02 13:58:49 +02:00
TelemetryHelper.ps1 dotnet err 2023-01-31 06:30:54 +01:00
Version.txt add trustServerCertificate if the parameter exists (#3579) 2024-07-06 15:34:38 +02:00
addfonts.ps1 Issue #2097 2021-09-30 14:15:33 +02:00

README.md

BcContainerHelper

BcContainerHelper is a PowerShell module designed to simplify the management of Business Central and Dynamics NAV containers on Docker. As a work-in-progress project, it welcomes contributions through pull requests and ideas. Comprehensive documentation is available in the NavContainerHelper.md.

Getting Started

There are two primary methods for running these Docker containers: as a VM on Azure or locally.

Using a VM on Azure provides a ready-to-go environment within approximately 30 minutes, eliminating the need for manual installation. If you have Azure credits as part of a Visual Studio subscription, you can use them for these VMs, making it a cost-effective option.

While local installation requires more initial setup, it offers a fully configured local environment where you can work with Business Central containers even offline.

VM on Azure

To set up a VM on Azure, follow the steps provided at aka.ms/getbc.

Local Installation

Local installation depends on whether you use Windows 10 or 11 or Windows Server.

You can choose between Hyper-V isolation or Process isolation:

Feature Hyper-V Isolation Process Isolation
Isolation Level High: Uses a separate hypervisor-based virtual machine Moderate: Uses namespace and resource control to isolate containers within the same OS instance
Performance Lower: Due to the overhead of running a full VM Higher: Less overhead, as it runs directly on the host OS kernel
Compatibility Can run different OS versions from the host Limited to running containers that share the same OS and kernel version as the host
Resource Requirements Higher: Requires more CPU and memory due to full VM overhead Lower: More efficient use of CPU and memory resources
Startup Time Slower: Takes longer to start due to VM initialization Faster: Quick startup as it leverages the host OS directly
Host OS Requirements Requires Windows or Windows Server with Hyper-V enabled Requires Windows or Windows Server with container support enabled

If you can use Process isolation, choose Hyper-V only if necessary due to compatibility issues like using Windows 10.

For more details on setting up your environment, visit the official documentation.

Local Installation on Windows 10 or 11

You can choose between Docker Desktop and installing the Docker Engine via PowerShell.

Before installing Docker, ensure your system meets the following requirements:

  • Windows 11 Pro, Enterprise, or Education edition.
  • Recommended minimum of 16 GB memory (more is better for running multiple containers simultaneously).

For Hyper-V:

  • More memory is recommended as the whole OS runs inside the Docker container VMs.
  • A 64-bit processor with Second Level Address Translation (SLAT).
  • CPU support for VM Monitor Mode Extension (VT-c on Intel CPUs). Enable hardware virtualization support in the BIOS settings.

1.a Install Docker Desktop

Note: Docker Desktop may require a license. Please review the licensing rules before installing and also check out the System Requirements.

Download and install Docker Desktop from docker.com. It will install the Windows Features Containers and Hyper-V.

By default, the Windows Subsystem for Linux (WSL) is enabled, which runs Linux instead of Windows containers.

During installation, set the default container type to Windows containers. To switch after installation, open the system tray, right-click on the Docker icon, and select Switch to Windows containers....

For more details, visit this Microsoft guide.

1.b Alternative: Install Docker Engine using PowerShell

Install the Windows Feature Containers and optionally Hyper-V.

  1. Open Control Panel:

    • Press Win + R to open the Run dialog box.
    • Type Control Panel and press Enter.
  2. Navigate to Programs and Features:

    • In the Control Panel, click on Programs.
    • Under Programs and Features, click Turn Windows features on or off.
  3. Enable Containers:

    • In the Windows Features dialog, scroll down and locate Containers.
    • Check the box next to Containers to enable it.
  4. (Optionally) Enable Hyper-V:

    • In the Windows Features dialog, scroll down and locate Hyper-V.
    • Check the box next to Hyper-V to enable it.
  5. Apply Changes and Restart:

    • Click OK to apply the changes.
    • Windows will begin installing Containers and Hyper-V, which might take a few minutes.
    • After the installation is complete, you will be prompted to restart your computer. Click Restart now to complete the installation.

Your computer will restart.

Run PowerShell as an administrator:

Invoke-WebRequest -UseBasicParsing -Uri 'https://raw.githubusercontent.com/microsoft/nav-arm-templates/master/InstallOrUpdateDockerEngine.ps1' -OutFile (Join-Path $ENV:TEMP 'installOrUpdateDocker.ps1')
. (Join-Path $ENV:TEMP 'installOrUpdateDocker.ps1')

2. Install BcContainerHelper

Run PowerShell as an administrator:

Install-PackageProvider -Name NuGet -Force
Install-Module BcContainerHelper -Force
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned

Note: On Windows 11, you also need to allow running modules with Set-ExecutionPolicy -ExecutionPolicy RemoteSigned. For more details, see this link.

3. Create Your First Container

Run PowerShell as an administrator:

$url = Get-BCArtifactUrl -Select Latest -Type OnPrem -Country w1
$cred = Get-Credential
New-BcContainer -accept_eula -artifactUrl $url -Credential $cred -auth UserPassword

With these steps, you should be able to set up your environment and start using BcContainerHelper to create and manage Business Central containers on Docker.

Local Installation on Windows Server

1. Install Docker

Before installing Docker, ensure your system meets the following requirements:

  • Windows Server 2016, 2019, or 2022 Standard or Datacenter Edition.
  • Recommended minimum of 16 GB memory (more is better for running multiple containers simultaneously).

For Hyper-V:

  • More memory is recommended as the whole OS runs inside the VM.
  • A 64-bit processor with Second Level Address Translation (SLAT).
  • CPU support for VM Monitor Mode Extension (VT-c on Intel CPUs). Enable hardware virtualization support in the BIOS settings.

Run PowerShell as an administrator:

Install-WindowsFeature Containers -Restart

If you want to use Hyper-V, run Install-WindowsFeature Hyper-V, Containers -Restart instead. More details on using Hyper-V can be found in the Business Central Generic Images section.

Your computer will restart.

Run PowerShell as an administrator:

Invoke-WebRequest -UseBasicParsing -Uri 'https://raw.githubusercontent.com/microsoft/nav-arm-templates/master/InstallOrUpdateDockerEngine.ps1' -OutFile (Join-Path $ENV:TEMP 'installOrUpdateDocker.ps1')
. (Join-Path $ENV:TEMP 'installOrUpdateDocker.ps1')

2. Install BcContainerHelper

Run PowerShell as an administrator:

Install-PackageProvider -Name NuGet -Force
Install-Module BcContainerHelper -Force

3. Create Your First Container

Run PowerShell as an administrator:

$url = Get-BCArtifactUrl -Select Latest -Type OnPrem -Country w1
$cred = Get-Credential
New-BcContainer -accept_eula -artifactUrl $url -Credential $cred -auth UserPassword

With these steps, you should be able to set up your environment and start using BcContainerHelper to create and manage Business Central containers on Docker.

Business Central Generic Images

Business Central Generic images are named mcr.microsoft.com/businesscentral:osversion, where osversion is the version of the Operating System.

BcContainerHelper attempts to find the best matching generic image for your OS. A new generic image is created monthly for all supported long-term servicing channels (LTSC). Currently, this includes three images:

  • mcr.microsoft.com/businesscentral:ltsc2016
  • mcr.microsoft.com/businesscentral:ltsc2019
  • mcr.microsoft.com/businesscentral:ltsc2022

These images will also be tagged with the osversion, but BcContainerHelper's Get-BestGenericImage will (by default) always return one of the three images above.

  • Windows 10 will always get ltsc2019 and will need Hyper-V isolation to run these.
  • Windows 11 will always get ltsc2022 and can still run process isolation.
  • Windows Server 2019 can run process isolation with a matching image.
  • Windows Server 2022 can run process isolation with the latest image

Branches

NavContainerHelper is the main repo for the NavContainerHelper PowerShell module on PowerShell Gallery. NavContainerHelper will as of August 1st 2020 only receive bug fixes.

master is the main repo for the BcContainerHelper PowerShell module on PowerShell Gallery. BcContainerHelper will from August 1st 2020 ship as release and pre-release.

Please report issues in the issues list.

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.

When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.