Navcontainerhelper: Script creating an unwanted multitenant environment

Created on 27 Feb 2021  路  6Comments  路  Source: microsoft/navcontainerhelper

Describe the issue
If I run the script below, I expect to get a new single tenant container and a new database on my local host sql server.
Instead it's setting up an multitenant environment. Am I missing something?

PS: I could fix the problem by setting $bcContainerHelperConfig.sandboxContainersAreMultitenantByDefault = $false but this is just a workaround in my eyes. (As I am not trying to create a sandbox container)

Scripts used to create container and cause the issue

$containerName = 'CONT1'
$credential = Get-Credential -Message 'Using UserPassword authentication. Please enter credentials for the container.'
$auth = 'UserPassword'
$artifactUrl = Get-BcArtifactUrl -type 'OnPrem' -version '17.4' -country 'de' -select 'Latest'
$databaseServer = 'host.containerhelper.internal'
$databaseInstance = ''
$databasePrefix = 'PREFIX'
$databaseName = 'BC'
$databaseUsername = ''
$databasePassword = ''
$databaseSecurePassword = ConvertTo-SecureString -String $databasePassword -AsPlainText -Force
$databaseCredential = New-Object pscredential $databaseUsername, $databaseSecurePassword
$licenseFile = 'C:\temp\license.flf'
New-BcContainer `
    -accept_eula `
    -containerName $containerName `
    -credential $credential `
    -auth $auth `
    -artifactUrl $artifactUrl `
    -imageName '170cu4-image' `
    -databaseServer $databaseServer -databaseInstance $databaseInstance -databaseName $databaseName -databasePrefix $databasePrefix `
    -databaseCredential $databaseCredential `
    -licenseFile $licenseFile `
    -updateHosts `
    -myScripts @("additional_setup.ps1") `
    -addFontsFromPath '.\fonts\' `
    -replaceExternalDatabases

Full output of scripts (I only included the start, as it is already showing the multitenant image creation)

BcContainerHelper is version 2.0.5
BcContainerHelper is running as administrator
Host is Microsoft Windows 10 Pro - 20H2
Docker Client Version is 20.10.2
Docker Server Version is 20.10.2
Setting database PREFIXBC offline
Removing database PREFIXBC
Starting Database Restore job from https://bcartifacts.azureedge.net/onprem/17.4.21491.21531/de
Fetching all docker images
ArtifactUrl and ImageName specified
Building multitenant image 170cu4-image:onprem-17.4.21491.21531-de-nodb-mt based on mcr.microsoft.com/businesscentral:10.0.19042.804 with https://bcartifacts.azureedge.net/onprem/17.4.21491.21531/de without database
Pulling latest image mcr.microsoft.com/businesscentral:10.0.19042.804
10.0.19042.804: Pulling from businesscentral
Digest: sha256:81b6cbd92ba5ce99ca5078a5eebd77e55d27d60bf7710845f62392e9419096a0
Status: Image is up to date for mcr.microsoft.com/businesscentral:10.0.19042.804
mcr.microsoft.com/businesscentral:10.0.19042.804
Generic Tag: 1.0.1.3
...

Additional context

  • does it happen all the time?
    Yes
  • did it use to work?
    No
bug Fix Ready Ships in a future version

All 6 comments

I think I found the problem:

https://github.com/microsoft/navcontainerhelper/blob/cf823932ee8731a055ca016a786b3fc5e394b685/ContainerHandling/New-NavContainer.ps1#L502
Shouldn't this be if ($bcstyle -eq "sandbox" -and (!($PSBoundParameters.ContainsKey('multitenant')))) {?

Yes, exactly - that is the bug.

Too many different programming languages....:-)
Will submit a fix shortly

Thanks for the very detailed repro step - basically copy/paste, fix a few things and run - and I could see the same issue.
Found the bug the same time as you - within 10 minutes:-)

Thanks for the quick response and fix. :)

Shipped in BcContainerHelper 2.0.6

Was this page helpful?
0 / 5 - 0 ratings