microsoft / navcontainerhelper

Official Microsoft repository for BcContainerHelper, a PowerShell module, which makes it easier to work with Business Central Containers on Docker.
MIT License
379 stars 243 forks source link

External Database - Faulting module name: KERNELBASE.dll Cannot create container #3605

Closed kevindstanley closed 1 month ago

kevindstanley commented 1 month ago

Describe the issue Creating a container fails when using external sql. This is basically the same issue as 3601, but that issue is closed, but the root issue is still occurring.

I cannot create a container using the external sql for artifacts relating to 24.0, 24.2 or 24.3 and I tried your idea in issue 3601 of using an OnPrem artifact. That creates the container in OnPrem, but then I cannot later mount a bacpac from cloud to that OnPrem container because of missing default apps(or different versions on cloud vs OnPrem) on from the cloud bacpac. This is a real problem effecting our day to day development processes.

For sql I notice in the database creation previously it was creating a "Cronus", "default", and "tenant" databases in my sql server. It is no longer doing that, and is only creating "Cronus" and "tenant" databases when viewed from SQL Server Management Studio after the script fails.

Also - if I switch to not external sql and use the internal SQL Express in the docker container, it creates the container just fine, but we have been using external sql for databases larger than 10gb for years.

Scripts used to create container and cause the issue

$databaseServer = "MyMachineName"
$databaseInstance = ""
$containerName = "testing"

if ($null -eq $databaseCredential) {
    $databaseCredential = Get-Credential
}

$licenseFile = "C:\workpath\license\latest.bclicense"

# $artifactUrl = Get-BCArtifactUrl -type Sandbox -country "ca" -version "24.0"  
$artifactUrl = "https://bcartifacts-exdbf9fwegejdqak.b02.azurefd.net/sandbox/24.0.16410.22272/ca"
# $artifactUrl = "https://bcartifacts-exdbf9fwegejdqak.b02.azurefd.net/sandbox/24.2.20227.22276/ca" # also does not work
# $artifactUrl = "https://bcartifacts-exdbf9fwegejdqak.b02.azurefd.net/sandbox/24.3.21374.22278/ca" # also does not work

$databaseParams = @{
    "databaseServer"     = "$databaseServer"
    "databaseInstance"   = "$databaseInstance"
    "databasePrefix"     = "$($containerName)-"
    "databaseName"       = "CRONUS"
    "databaseCredential" = $databaseCredential
    "multitenant"        = $true
}

New-BcContainer @databaseParams -replaceExternalDatabases `
    -accept_eula `
    -containerName "$containerName" `
    -credential $containerCredential `
    -auth UserPassword `
    -artifactUrl $artifactUrl `
    -licenseFile $licenseFile `
    -updateHosts `
    -assignPremiumPlan `
    -accept_outdated `
    -memoryLimit "12G" `
    -shortcuts None `
    -isolation process

Full output of scripts

cmdlet Get-Credential at command pipeline position 1
Supply values for the following parameters:
Credential
BcContainerHelper version 6.0.17
WinRM service is not running, will not try to use WinRM sessions
BC.HelperFunctions emits usage statistics telemetry to Microsoft
Running on Windows, PowerShell 5.1.22621.3880
BcContainerHelper is version 6.0.17
BcContainerHelper is running as administrator
HyperV is Enabled
Host is Microsoft Windows 11 Pro - 10.0.22631.3880
UsePsSession is True
UsePwshForBc24 is True
UseWinRmSession is never
UseSslForWinRmSession is True
Docker Client Version is 20.10.21
Docker Server Version is 20.10.21
Removing Session testing
Removing container testing
Removing entries from hosts
Removing testing from container hosts file
Removing testing-* from container hosts file
Removing Desktop shortcuts
Removing C:\ProgramData\BcContainerHelper\Extensions\testing
Setting database testing-tenant offline
Removing database testing-tenant
Setting database testing-CRONUS offline
Removing database testing-CRONUS
Starting Database Restore job from https://bcartifacts-exdbf9fwegejdqak.b02.azurefd.net/sandbox/24.0.16410.22272/ca
C:\Program Files\WindowsPowerShell\Modules\BcContainerHelper\6.0.17\Import-BcContainerHelper.ps1
Fetching all docker images
Fetching all docker volumes
Using image mcr.microsoft.com/businesscentral:ltsc2022
Creating Container testing
Style: sandbox
Multitenant: Yes
Version: 24.0.16410.22272
Platform: 24.0.22214.0
Generic Tag: 1.0.2.39
Container OS Version: 10.0.20348.2582 (ltsc2022)
Host OS Version: 10.0.22631.3880 (23H2)
Using process isolation
Using locale en-CA
Disabling the standard eventlog dump to container log every 2 seconds (use -dumpEventLog to enable)
Using license file C:\workpath\license\latest.bclicense
Files in C:\ProgramData\BcContainerHelper\Extensions\testing\my:
- AdditionalOutput.ps1
- HelperFunctions.ps1
- license.bclicense
- MainLoop.ps1
- SetupDatabase.ps1
- SetupVariables.ps1
- updatehosts.ps1
Creating container testing from image mcr.microsoft.com/businesscentral:ltsc2022
Using Shared Encryption Key file
2a8e1c1b63d735d80265175e5e62158abacf33381c18931810da71d72dc3097d
Waiting for container testing to be ready
Using artifactUrl https://bcartifacts-exdbf9fwegejdqak.b02.azurefd.net/sandbox/24.0.16410.22272/ca
Using installer from C:\Run\240
Installing Business Central: multitenant=True, installOnly=False, filesOnly=False, includeTestToolkit=False, includeTestLibrariesOnly=False, includeTestFrameworkOnly=False, includePerformanceToolkit=False, appArtifactPath=c:\dl\sandbox\24.0.16410.22272\ca, platformArtifactPath=c:\dl\sandbox\24.0.16410.22272\platform, databasePath=, licenseFilePath=c:\dl\sandbox\24.0.16410.22272\ca\Cronus.bclicense, rebootContainer=True
Installing from artifacts
Starting Local SQL Server
Starting Internet Information Server
Copying Service Tier Files
c:\dl\sandbox\24.0.16410.22272\platform\ServiceTier\Program Files
c:\dl\sandbox\24.0.16410.22272\platform\ServiceTier\System64Folder
Copying Web Client Files
c:\dl\sandbox\24.0.16410.22272\platform\WebClient\Microsoft Dynamics NAV
Copying ModernDev Files
c:\dl\sandbox\24.0.16410.22272\platform
c:\dl\sandbox\24.0.16410.22272\platform\ModernDev\program files\Microsoft Dynamics NAV
Copying additional files
Copying ConfigurationPackages
C:\dl\sandbox\24.0.16410.22272\ca\ConfigurationPackages
Copying Test Assemblies
C:\dl\sandbox\24.0.16410.22272\platform\Test Assemblies
Copying Extensions
C:\dl\sandbox\24.0.16410.22272\ca\Extensions
Copying Applications
C:\dl\sandbox\24.0.16410.22272\platform\Applications
Copying Applications.CA
C:\dl\sandbox\24.0.16410.22272\ca\Applications.CA
Copying dependencies
Importing PowerShell Modules
Skipping restore of Cronus database
Modifying Business Central Service Tier Config File for Docker
Creating Business Central Service Tier
Installing SIP crypto provider: 'C:\Windows\System32\NavSip.dll'
Installation took 7 seconds
Installation complete
Initializing...
Setting host.docker.internal to 192.168.1.20 in container hosts file (copy from host hosts file)
Setting gateway.docker.internal to 192.168.1.20 in container hosts file (copy from host hosts file)
Setting kubernetes.docker.internal to 127.0.0.1 in container hosts file (copy from host hosts file)
Setting host.containerhelper.internal to 172.26.176.1 in container hosts file
Starting Container
Hostname is testing
PublicDnsName is testing
Using NavUserPassword Authentication
Waiting for database creation to finish
Success
Import Encryption Key
Stopping local SQL Server
Creating Self Signed Certificate
Self Signed Certificate Thumbprint B110198CA63447A39803FB6E1EDD409C2337748C
DNS identity testing
Modifying Service Tier Config File with Instance Specific Settings
Starting Service Tier
Service 'Dynamics 365 Business Central Server [BC] (MicrosoftDynamicsNavServer$BC)' cannot be started due to the following error: Cannot start service MicrosoftDynamicsNavServer$BC on computer '.'.
at <ScriptBlock>, C:\Run\navstart.ps1: line 175
at <ScriptBlock>, C:\Run\start.ps1: line 390
at <ScriptBlock>, <No file>: line 1Error
Using artifactUrl https://bcartifacts-exdbf9fwegejdqak.b02.azurefd.net/sandbox/24.0.16410.22272/ca
Using installer from C:\Run\240
Installing Business Central: multitenant=True, installOnly=False, filesOnly=False, includeTestToolkit=False, includeTestLibrariesOnly=False, includeTestFrameworkOnly=False, includePerformanceToolkit=False, appArtifactPath=c:\dl\sandbox\24.0.16410.22272\ca, platformArtifactPath=c:\dl\sandbox\24.0.16410.22272\platform, databasePath=, licenseFilePath=c:\dl\sandbox\24.0.16410.22272\ca\Cronus.bclicense, rebootContainer=True
Installing from artifacts
Starting Local SQL Server
Starting Internet Information Server
Copying Service Tier Files
c:\dl\sandbox\24.0.16410.22272\platform\ServiceTier\Program Files
c:\dl\sandbox\24.0.16410.22272\platform\ServiceTier\System64Folder
Copying Web Client Files
c:\dl\sandbox\24.0.16410.22272\platform\WebClient\Microsoft Dynamics NAV
Copying ModernDev Files
c:\dl\sandbox\24.0.16410.22272\platform
c:\dl\sandbox\24.0.16410.22272\platform\ModernDev\program files\Microsoft Dynamics NAV
Copying additional files
Copying ConfigurationPackages
C:\dl\sandbox\24.0.16410.22272\ca\ConfigurationPackages
Copying Test Assemblies
C:\dl\sandbox\24.0.16410.22272\platform\Test Assemblies
Copying Extensions
C:\dl\sandbox\24.0.16410.22272\ca\Extensions
Copying Applications
C:\dl\sandbox\24.0.16410.22272\platform\Applications
Copying Applications.CA
C:\dl\sandbox\24.0.16410.22272\ca\Applications.CA
Copying dependencies
Importing PowerShell Modules
Skipping restore of Cronus database
Modifying Business Central Service Tier Config File for Docker
Creating Business Central Service Tier
Installing SIP crypto provider: 'C:\Windows\System32\NavSip.dll'
Installation took 7 seconds
Installation complete
Initializing...
Setting host.docker.internal to 192.168.1.20 in container hosts file (copy from host hosts file)
Setting gateway.docker.internal to 192.168.1.20 in container hosts file (copy from host hosts file)
Setting kubernetes.docker.internal to 127.0.0.1 in container hosts file (copy from host hosts file)
Setting host.containerhelper.internal to 172.26.176.1 in container hosts file
Starting Container
Hostname is testing
PublicDnsName is testing
Using NavUserPassword Authentication
Waiting for database creation to finish
Success
Import Encryption Key
Stopping local SQL Server
Creating Self Signed Certificate
Self Signed Certificate Thumbprint B110198CA63447A39803FB6E1EDD409C2337748C
DNS identity testing
Modifying Service Tier Config File with Instance Specific Settings
Starting Service Tier
Service 'Dynamics 365 Business Central Server [BC] (MicrosoftDynamicsNavServer$BC)' cannot be started due to the following error: Cannot start service MicrosoftDynamicsNavServer$BC on computer '.'.
at <ScriptBlock>, C:\Run\navstart.ps1: line 175
at <ScriptBlock>, C:\Run\start.ps1: line 390
at <ScriptBlock>, <No file>: line 1
New-BcContainer Telemetry Correlation Id: aa3fb56e-9a86-47fe-b0bd-24e0990a4437
Initialization of container testing failed
At C:\Program Files\WindowsPowerShell\Modules\BcContainerHelper\6.0.17\ContainerHandling\Wait-NavContainerReady.ps1:42 char:17
+ ...             throw "Initialization of container $containerName failed" ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (Initialization ... testing failed:String) [], RuntimeException
    + FullyQualifiedErrorId : Initialization of container testing failed

Additional context

HeWessel commented 1 month ago

We currently facing the same Problem. Sandbox Version 23 and 24 get this Error. Sandbox Version 22 doesnt has any problems to create a Container. We are still on Windows Server 2019, if that information is helpful.

LennyHadley2 commented 1 month ago

I am currently facing the same problem described here. We are unable to create any containers locally at this point from 23 and 24.

amandajb27 commented 1 month ago

Having same issue, cannot create a container for client cloud DB's. I noticed issue last Thursday, about two weeks ago I was having no issues. My restore attempts were 24.0 and 24.2

freddydk commented 1 month ago

Does anybody know whether BC 23 used to work - and stopped working?

kevindstanley commented 1 month ago

23 did used to work, I haven't had to use it in a few weeks since all of our customers have upgraded to v24, but we used v23 for the full 6 months that customers were on it with our automated processes.

HeWessel commented 1 month ago

We occured the Problem first at the 20th of July with the BC23 Container.

freddydk commented 1 month ago

This was important information.

Just tested, and found that if you use:

Get-BCArtifactUrl -country us -version '23.3' -before ([datetime]::new(2024,07,19))

for BC 23.3 or

Get-BCArtifactUrl -country us -before ([datetime]::new(2024,07,19))

for BC 24.3, then it works (on my machine)

Specifically - version 24.3.21374.22054 works, 24.3.21374.22069 doesn't

I will file a bug on server team.

kevindstanley commented 1 month ago

I tested and it works for the moment.

This will unfortunately discontinue working if there is a hotfix release that goes out to cloud that is newer than the most recent known working artifact version of 24.3.21374.22054. For example if/when Microsoft releases a hotfix to cloud >= 24.3.21374.22055 and the customer on cloud gets updated to that, then their bacpac export will no longer be able to be mounted to the 24.3.21374.22054 version of the container.

At least for now we have a temporary solution until the server team releases a fix! Thanks!

edit: fixed version numbers to match your post.

freddydk commented 1 month ago

Obviously we need to provide a fix for the artifacts, we are looking at what went wrong.

freddydk commented 1 month ago

A fix for all versions affected by this bug has been shipped and you should be able to download the latest artifact and make this work. (just tried with the latest 24 and the latest 23.3)