microsoft / navcontainerhelper

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

External Database - Faulting module name: KERNELBASE.dll #3601

Closed FelixHaemsch closed 3 months ago

FelixHaemsch commented 3 months ago

Description I want to create a BC 23.3 container with external database on local sql server 2019. The scripts fails when trying to start the bc server instance. When I create the container without an external database it works. I also tried combinations of windows and NAVUserPassword authentication and process and hyperv isolation. The database is created successfully on my local sql server. I tried using PS 7.42 and PS 5.1

Scripts used to create container and cause the issue

$licenseFile = "C:\Sources\German Developer License BC24.bclicense"
$auth = "NavUserPassword"
$credential = Get-Credential
$artifactUrl = Get-BcArtifactUrl -country de -version '23.3'
$artifactUrl
$sqlPassword = ConvertTo-SecureString "<password>" -AsPlainText -Force
$sqlUser = 'sa'

$containerName = "bccontainer"

$databaseParams = @{
    "databaseServer" = 'host.containerhelper.internal'
    "databaseInstance" = ''
    "databasePrefix" = "$containerName-"
    "databaseName" = 'alpaca'
    "databaseCredential" = New-Object pscredential $sqlUser, $sqlPassword
    "multitenant" = $false
}

New-BcContainer @databaseParams -replaceExternalDatabases `
    -accept_eula `
    -containerName $containerName `
    -credential $credential `
    -auth $auth `
    -artifactUrl $artifactUrl `
    -licenseFile $licenseFile `
    -updateHosts `
    -alwaysPull `
    -forceRebuild `
    -isolation hyperv

Full output of scripts

New-BcContainer @databaseParams -replaceExternalDatabases `
    -accept_eula `
    -containerName $containerName `
    -credential $credential `
    -auth $auth `
    -artifactUrl $artifactUrl `
    -licenseFile $licenseFile `
    -updateHosts `
    -alwaysPull `
    -forceRebuild `
    -isolation hyperv
BcContainerHelper is version 6.0.20-preview1214
BcContainerHelper is running as administrator
HyperV is Disabled
Host is Microsoft Windows 11 Enterprise - 10.0.22631.3880
UsePsSession is True
UsePwshForBc24 is True
UseWinRmSession is never
UseSslForWinRmSession is True
Docker Client Version is 27.0.3
Docker Server Version is 24.0.5
Removing Session bccontainer
Removing container bccontainer
Removing entries from hosts
Removing bccontainer from container hosts file
Removing bccontainer-* from container hosts file
Removing Desktop shortcuts
Removing C:\ProgramData\BcContainerHelper\Extensions\bccontainer
Setting database bccontainer-alpaca offline
Removing database bccontainer-alpaca
Starting Database Restore job from https://bcartifacts-exdbf9fwegejdqak.b02.azurefd.net/sandbox/23.3.14876.22140/de
C:\Program Files\WindowsPowerShell\Modules\BcContainerHelper\6.0.20\Import-BcContainerHelper.ps1
Fetching all docker images
Fetching all docker volumes
Pulling image mcr.microsoft.com/businesscentral:ltsc2022-dev
ltsc2022-dev: Pulling from businesscentral
Digest: sha256:4f18913f58dafe2af1e083627559ed74aabaf919b7b28d10e148cdbaf2ec49c0
Status: Image is up to date for mcr.microsoft.com/businesscentral:ltsc2022-dev
Using image mcr.microsoft.com/businesscentral:ltsc2022-dev
Creating Container bccontainer
Style: sandbox
Multitenant: No
Version: 23.3.14876.22140
Platform: 23.0.22115.0
Generic Tag: 1.0.2.39-dev
Container OS Version: 10.0.20348.2582 (ltsc2022)
Host OS Version: 10.0.22631.3880 (23H2)
Using hyperv isolation
Using locale de-DE
Disabling the standard eventlog dump to container log every 2 seconds (use -dumpEventLog to enable)
Using license file C:\Sources\German Developer License BC24.bclicense
Files in C:\ProgramData\BcContainerHelper\Extensions\bccontainer\my:
- AdditionalOutput.ps1
- HelperFunctions.ps1
- license.bclicense
- MainLoop.ps1
- SetupDatabase.ps1
- SetupVariables.ps1
- updatehosts.ps1
Creating container bccontainer from image mcr.microsoft.com/businesscentral:ltsc2022-dev
b55a1dcea355e327a8b4a594f542d12781aab5761dfbe7f4b3aacf782dd10a28
Waiting for container bccontainer to be ready
Using artifactUrl https://bcartifacts-exdbf9fwegejdqak.b02.azurefd.net/sandbox/23.3.14876.22140/de
Using installer from C:\Run\210-new
Installing Business Central: multitenant=False, installOnly=False, filesOnly=False, includeTestToolkit=False, includeTestLibrariesOnly=False, includeTestFrameworkOnly=False, includePerformanceToolkit=False, appArtifactPath=c:\dl\sandbox\23.3.14876.22140\de, platformArtifactPath=c:\dl\sandbox\23.3.14876.22140\platform, databasePath=, licenseFilePath=c:\dl\sandbox\23.3.14876.22140\de\Cronus.bclicense, rebootContainer=True
Installing from artifacts
Starting Local SQL Server
Starting Internet Information Server
Copying Service Tier Files
c:\dl\sandbox\23.3.14876.22140\platform\ServiceTier\Program Files
c:\dl\sandbox\23.3.14876.22140\platform\ServiceTier\System64Folder
Copying PowerShell Scripts
c:\dl\sandbox\23.3.14876.22140\platform\WindowsPowerShellScripts\Cloud\NAVAdministration
c:\dl\sandbox\23.3.14876.22140\platform\WindowsPowerShellScripts\WebSearch
Copying Web Client Files
c:\dl\sandbox\23.3.14876.22140\platform\WebClient\Microsoft Dynamics NAV
Copying ModernDev Files
c:\dl\sandbox\23.3.14876.22140\platform
c:\dl\sandbox\23.3.14876.22140\platform\ModernDev\program files\Microsoft Dynamics NAV
Copying additional files
Copying ConfigurationPackages
C:\dl\sandbox\23.3.14876.22140\de\ConfigurationPackages
Copying Test Assemblies
C:\dl\sandbox\23.3.14876.22140\platform\Test Assemblies
Copying Extensions
C:\dl\sandbox\23.3.14876.22140\de\Extensions
Copying Applications
C:\dl\sandbox\23.3.14876.22140\platform\Applications
Copying Applications.DE
C:\dl\sandbox\23.3.14876.22140\de\Applications.DE
Copying dependencies
Copying ReportBuilder
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 17 seconds
Installation complete
Initializing...
Setting host.containerhelper.internal to 172.18.80.1 in container hosts file
Starting Container
Hostname is bccontainer
PublicDnsName is bccontainer
WARNING: Container starts with TimeZone = Mitteleuropäische Zeit, which is not recognized in the list of TimeZones.   
Using NavUserPassword Authentication
Success
Import Encryption Key
Cannot establish a connection to the SQL Server/Database.

This could be due to one of the following reasons:

* SQL Server is not started.
* The database does not exist.
* Proper permissions have not been given to the NAV Server Account.

Try again later or contact your system administrator.
at <ScriptBlock>, C:\run\setupDatabase.ps1: line 152
at <ScriptBlock>, C:\Run\my\SetupDatabase.ps1: line 2
at <ScriptBlock>, C:\Run\navstart.ps1: line 141
at <ScriptBlock>, C:\Run\start.ps1: line 390
at <ScriptBlock>, <No file>: line 1Error
Using artifactUrl https://bcartifacts-exdbf9fwegejdqak.b02.azurefd.net/sandbox/23.3.14876.22140/de
Using installer from C:\Run\210-new
Installing Business Central: multitenant=False, installOnly=False, filesOnly=False, includeTestToolkit=False, includeTestLibrariesOnly=False, includeTestFrameworkOnly=False, includePerformanceToolkit=False, appArtifactPath=c:\dl\sandbox\23.3.14876.22140\de, platformArtifactPath=c:\dl\sandbox\23.3.14876.22140\platform, databasePath=, licenseFilePath=c:\dl\sandbox\23.3.14876.22140\de\Cronus.bclicense, rebootContainer=True
Installing from artifacts
Starting Local SQL Server
Starting Internet Information Server
Copying Service Tier Files
c:\dl\sandbox\23.3.14876.22140\platform\ServiceTier\Program Files
c:\dl\sandbox\23.3.14876.22140\platform\ServiceTier\System64Folder
Copying PowerShell Scripts
c:\dl\sandbox\23.3.14876.22140\platform\WindowsPowerShellScripts\Cloud\NAVAdministration
c:\dl\sandbox\23.3.14876.22140\platform\WindowsPowerShellScripts\WebSearch
Copying Web Client Files
c:\dl\sandbox\23.3.14876.22140\platform\WebClient\Microsoft Dynamics NAV
Copying ModernDev Files
c:\dl\sandbox\23.3.14876.22140\platform
c:\dl\sandbox\23.3.14876.22140\platform\ModernDev\program files\Microsoft Dynamics NAV
Copying additional files
Copying ConfigurationPackages
C:\dl\sandbox\23.3.14876.22140\de\ConfigurationPackages
Copying Test Assemblies
C:\dl\sandbox\23.3.14876.22140\platform\Test Assemblies
Copying Extensions
C:\dl\sandbox\23.3.14876.22140\de\Extensions
Copying Applications
C:\dl\sandbox\23.3.14876.22140\platform\Applications
Copying Applications.DE
C:\dl\sandbox\23.3.14876.22140\de\Applications.DE
Copying dependencies
Copying ReportBuilder
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 17 seconds
Installation complete
Initializing...
Setting host.containerhelper.internal to 172.18.80.1 in container hosts file
Starting Container
Hostname is bccontainer
PublicDnsName is bccontainer
WARNING: Container starts with TimeZone = Mitteleuropäische Zeit, which is not recognized in the list of TimeZones.   
Using NavUserPassword Authentication
Success
Import Encryption Key
Cannot establish a connection to the SQL Server/Database.

This could be due to one of the following reasons:

* SQL Server is not started.
* The database does not exist.
* Proper permissions have not been given to the NAV Server Account.

Try again later or contact your system administrator.
at <ScriptBlock>, C:\run\setupDatabase.ps1: line 152
at <ScriptBlock>, C:\Run\my\SetupDatabase.ps1: line 2
at <ScriptBlock>, C:\Run\navstart.ps1: line 141
at <ScriptBlock>, C:\Run\start.ps1: line 390
at <ScriptBlock>, <No file>: line 1
New-BcContainer Telemetry Correlation Id: 3ebf9c5c-9ed7-4653-9a7b-469de5963a0b
Initialization of container bccontainer failed
At C:\Program
Files\WindowsPowerShell\Modules\BcContainerHelper\6.0.20\ContainerHandling\Wait-NavContainerReady.ps1:42 char:17       
+ ...             throw "Initialization of container $containerName failed" ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (Initialization ...ontainer failed:String) [], RuntimeException        
    + FullyQualifiedErrorId : Initialization of container bccontainer failed

Container Event Log

PS C:\Sources\BGH\BGH_DE\Script> enter-BcContainer bccontainer
[BCCONTAINER]: PS5 C:\Run> get-eventLog -LogName Application -EntryType Error -Newest 10 | format-table -wrap
Exception calling "ReadLine" with "2" argument(s): "Specified method is not supported."
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : NotSupportedException

   Index Time          EntryType   Source                 InstanceID Message
   ----- ----          ---------   ------                 ---------- -------
    6410 Jul 23 11:34  Error       Software Protection    3221233670 License Activation (slui.exe) failed with the    
                                   Platform Service                  following error code:
                                                                     hr=0x8007232B
                                                                     Command-line arguments:
                                                                     RuleId=eeba1977-569e-4571-b639-7623d8bfecc0;Actio 
                                                                     n=AutoActivate;AppId=55c92734-d682-4d71-983e-d6ec 
                                                                     3f16059f;SkuId=ef6cfc9f-8c5d-44ac-9aad-de6a2ea0ae 
                                                                     03;NotificationInterval=1440;Trigger=TimerEvent   
    6407 Jul 23 11:34  Error       Software Protection    3221226513 Failed to collect hardware data. Error code       
                                   Platform Service                  0xD0000034.
    6400 Jul 23 11:33  Error       Application Error            1000 Faulting application name:
                                                                     Microsoft.Dynamics.Nav.Server.exe, version:       
                                                                     23.0.22115.0, time stamp: 0x666c0000
                                                                     Faulting module name: KERNELBASE.dll, version:    
                                                                     10.0.20348.2582, time stamp: 0xf8072450
                                                                     Exception code: 0xe0434352
                                                                     Fault offset: 0x000000000003f14c
                                                                     Faulting process id: 0x9e8
                                                                     Faulting application start time:
                                                                     0x01dadce35a6de320
                                                                     Faulting application path: C:\Program
                                                                     Files\Microsoft Dynamics
                                                                     NAV\230\Service\Microsoft.Dynamics.Nav.Server.exe 
                                                                     Faulting module path:
                                                                     C:\Windows\System32\KERNELBASE.dll
                                                                     Report Id: c48c6e9e-fb15-4152-89f0-62a1155e5ba4   
                                                                     Faulting package full name:
                                                                     Faulting package-relative application ID:
    6399 Jul 23 11:33  Error       .NET Runtime                 1026 Application: Microsoft.Dynamics.Nav.Server.exe    
                                                                     CoreCLR Version: 6.0.3224.31407
                                                                     .NET Version: 6.0.32
                                                                     Description: The process was terminated due to    
                                                                     an unhandled exception.
                                                                     Exception Info: System.NullReferenceException:    
                                                                     Object reference not set to an instance of an     
                                                                     object.
                                                                        at Microsoft.Dynamics.Nav.Types.ServerUserSett 
                                                                     ings.LoadProperties(Object target,
                                                                     SettingsProvider provider)
                                                                        at Microsoft.Dynamics.Nav.Types.ServerUserSett 
                                                                     ings.LoadSettings()
                                                                        at Microsoft.Dynamics.Nav.Types.ServerUserSett 
                                                                     ings.LoadAndValidateSettings()
                                                                        at Microsoft.Dynamics.Nav.Types.ServerUserSett 
                                                                     ings.CreateInstance(SettingsProvider
                                                                     settingsProvider, ConcurrentDictionary`2
                                                                     appSpecificSettings)
                                                                        at Microsoft.Dynamics.Nav.Types.ServerUserSett 
                                                                     ings.CreateInstance(SettingsProvider
                                                                     settingsProvider, Boolean forceRefresh)
                                                                        at Microsoft.Dynamics.Nav.Types.ServerUserSett 
                                                                     ings.CreateInstance(String fileName)
                                                                        at Microsoft.Dynamics.Nav.Types.ServerUserSett 
                                                                     ings.get_Instance()
                                                                        at Microsoft.Dynamics.Nav.Types.DiagnosticsExc 
                                                                     eptionsAllowList.SafeGetAllowedExceptionsForTelem 
                                                                     etry()
                                                                        at Microsoft.Dynamics.Nav.Types.DiagnosticsExc 
                                                                     eptionsAllowList.GenerateAllowedExceptionsSet()   
                                                                        at
                                                                     System.Lazy`1.ViaFactory(LazyThreadSafetyMode     
                                                                     mode)
                                                                     --- End of stack trace from previous location --- 
                                                                        at System.Lazy`1.CreateValue()
                                                                        at System.Lazy`1.get_Value()
                                                                        at Microsoft.Dynamics.Nav.Types.DiagnosticsExc 
                                                                     eptionsAllowList.IsExceptionAllowed(Exception     
                                                                     exception)
                                                                        at Microsoft.Dynamics.Nav.Diagnostic.NavDiagno 
                                                                     stics.ExceptionTelemetryMessages.AppendException( 
                                                                     Exception exception, String diagnosticsContext,   
                                                                     String callStack, Boolean&
                                                                     shouldEmitTransientTelemetry)
                                                                        at Microsoft.Dynamics.Nav.Diagnostic.NavDiagno 
                                                                     stics.ComposeExceptionTelemetryMessages(Exception 
                                                                      exception, String diagnosticsContext,
                                                                     DiagnosticParameter message, Boolean&
                                                                     shouldEmitTransientTelemetry)
                                                                        at Microsoft.Dynamics.Nav.Diagnostic.NavDiagno 
                                                                     stics.ComposeAndSendExceptionTraceTag(String      
                                                                     tag, Category category, Exception exception,      
                                                                     DiagnosticParameter message, Verbosity
                                                                     verbosity, Guid clientSessionId, Guid
                                                                     clientActivityId, String gatewayCorrelationId,    
                                                                     String diagnosticsContext, Boolean forceLog,      
                                                                     ValueTuple`2[] customDimensions)
                                                                        at Microsoft.Dynamics.Nav.Diagnostic.NavDiagno 
                                                                     stics.SendExceptionTag(String tag, Category       
                                                                     category, Exception exception, Verbosity
                                                                     verbosity, DiagnosticParameter message, String    
                                                                     diagnosticsContext, Boolean forceLog,
                                                                     ValueTuple`2[] customDimensions)
                                                                        at Microsoft.Dynamics.Nav.WindowsServices.Dyna 
                                                                     micsNavServer.CurrentDomain_UnhandledException(Ob 
                                                                     ject sender, UnhandledExceptionEventArgs e)       

      35 Jul 22 10:35  Error       Software Protection    3221226513 Failed to collect hardware data. Error code       
                                   Platform Service                  0xD0000034.
      30 Jul 22 10:34  Error       Software Protection    3221226513 Failed to collect hardware data. Error code       
                                   Platform Service                  0xD0000034.
      19 Jul 22 10:30  Error       Software Protection    3221233670 License Activation (slui.exe) failed with the     
                                   Platform Service                  following error code:
                                                                     hr=0x8007232B
                                                                     Command-line arguments:
                                                                     RuleId=eeba1977-569e-4571-b639-7623d8bfecc0;Actio 
                                                                     n=AutoActivate;AppId=55c92734-d682-4d71-983e-d6ec 
                                                                     3f16059f;SkuId=ef6cfc9f-8c5d-44ac-9aad-de6a2ea0ae 
                                                                     03;NotificationInterval=1440;Trigger=TimerEvent   
      14 Jul 22 10:30  Error       Software Protection    3221226513 Failed to collect hardware data. Error code       
                                   Platform Service                  0xD0000034.

Edit 1: corrected full output of script, becouse it was from a previous attempt with another version

freddydk commented 3 months ago

Is that output a result from that script?

image

vs.

image

FelixHaemsch commented 3 months ago

I am sorry. It seems that I copied the output from a previous attempt. I tried using different versions in case 23.3 was corrupted. I got the same error no matter what version I used. I edited my original post to correct this issue.

freddydk commented 3 months ago

I have a repro of this now - and it seems to go away if you use onprem artifacts. It works with artifacts prior to 23.0 with sandbox artifacts.

Please try to add -type onprem to your get-bcartifacturl and see if this solves the issue?

FelixHaemsch commented 3 months ago

Thank you very much for your fast feedback. I will try it and report back asap.

Regatoni commented 3 months ago

@freddydk Thank you for your Feedback

I tried it with the following image and it worked and created the Container -artifactUrl "https://bcartifacts-exdbf9fwegejdqak.b02.azurefd.net/onprem/24.3.21374.21517/ch"

So its a problem with the Sandbox image from Microsoft?

FelixHaemsch commented 3 months ago

I was finally able to try it and it worked like a charm. Thank you very much for your assistance.

marknitek commented 3 months ago

@freddydk so are we supposed to use the onprem artifacts now? this breaks our scripts... Will there be a proper fix for this?

freddydk commented 3 months ago

I don't know what happened here - but could see that this problem persists with version 23 as well as 24. Due to that, I have to prioritize this lower as a lot of the other things I have. If somebody can find out why this happens, I am open to review a PR or create a bug on the responsible team - else it will have to wait until I have the time.

kevindstanley commented 3 months ago

I don't know what happened here - but could see that this problem persists with version 23 as well as 24. Due to that, I have to prioritize this lower as a lot of the other things I have. If somebody can find out why this happens, I am open to review a PR or create a bug on the responsible team - else it will have to wait until I have the time.

Hi Freddy - since this ticket was closed, I had created a new one, but am not seeing any responses over there 3605. I have more details in that issue, but the point in the process that I am seeing differences and that usually it creates 3 databases(prefix-default, prefix-CRONUS and prefix-tenant) - it is no longer creating the prefix-tenant database, but still writing the log of 'Success' to the file databasescreated.txt(with the containername in front). Then it goes on to try to start the BC service and fails. I have also tried with a number of versions of bccontainerhelper(and preview versions), even older known working ones cannot create a sandbox container.

This issue has completely diminished our ability to work effectively. I have a team of 8 developers that cannot work on issues related to customer data. We use these bccontainerhelper tool extensively and have automated processes that happen when a ticket comes in - our tools generate a bacpac export, then it creates a docker container for their version of BC and mounts the customers database to the container. Many of these customers have databases greater than 10gb and cannot use SQL Express. Since all of them are on Cloud, they are all on v24, and no version of v24 currently creates a container successfully when using an external sql server.

freddydk commented 3 months ago

@kevindstanley - you should respond to the open issue.