microsoft / navcontainerhelper

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

Invoke-NAVApplicationDatabaseConversion #3735

Closed git-no closed 2 hours ago

git-no commented 1 day ago

Szenario

Convert an external database to the BC version from within the BC container. The BC container console is default Powershell 7.

Issue

Runing the BC command

Invoke-NAVApplicationDatabaseConversion -DatabaseServer a -Database b -Credential c

within the container (BC 24.6 also tested with 24.4) terminal (PS7) breaks with error

Could not load type 'Microsoft.Extensions.Logging.ILoggingBuilder' from assembly 'Microsoft.Extensions.Logging.Abstractions, Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.

Is there an issue with PS7 and Microsoft.Extensions.Logging.ILoggingBuilder version 5.0.0.0?

The database conversion did work till BC 23 / PS5.

Expectation

Microsoft Business Central command Invoke-NAVApplicationDatabaseConversion should work within the BC 24.x container.

Container Log

Docker version 4.34.2

BcContainerHelper is version 6.0.26
BcContainerHelper is running as administrator
HyperV is Enabled
Host is Microsoft Windows 11 Enterprise - 10.0.22631.4169
UsePsSession is True
UsePwshForBc24 is True
UseWinRmSession is allow
UseSslForWinRmSession is False
Docker Client Version is 27.2.0
Docker Server Version is 27.2.0
Removing Desktop shortcuts
Fetching all docker images
Fetching all docker volumes
Using image mcr.microsoft.com/businesscentral:ltsc2022
Disabling Health Check (always report healthy)
Creating Container X-GOAL
Style: onprem
Multitenant: No
Version: 24.6.25479.0
Platform: 24.0.25403.0
Generic Tag: 1.0.2.50
Container OS Version: 10.0.20348.2762 (ltsc2022)
Host OS Version: 10.0.22631.4169 (23H2)
Container and host OS are 20348 or above, not using SSL, recommended isolation mode is process.
Using process isolation
Using locale de-CH
Disabling the standard eventlog dump to container log every 2 seconds (use -dumpEventLog to enable)
Using license file C:\Users\l.nocinski\Source\upgrades\X\24\fin24.bclicense                                        
Adding X-GOAL to trusted hosts (meik-ext-dev,SGV-dev)
Additional Parameters:                                                                                                  
--env customNavSettings=ApiServicesEnabled=false,ApiSubscriptionsEnabled=false,BufferedInsertEnabled=true,ClientServicesMaxConcurrentConnections="2000",DataCacheSize="12",DisableSmartSql=true,EnableLongRunningSqlStatementsInDebugger=false,EnableSqlInformationDebugger=false,ManagementServicesIdleClientTimeout="12:00:00",SqlBulkImportBatchSize="10000",SqlConnectionIdleTimeout="00:05:00",SqlConnectionTimeout="00:01:30",SqlLongRunningThreshold="2000",SqlcontainerParamsByOrdinal=true,EnableTaskScheduler=False
--volume "C:\Users\l.nocinski\Source\upgrades\X\24:C:\Run\my\upgrade\24"
--volume "C:\Users\l.nocinski\Source\upgrades\X\Helper:C:\Run\my\upgrade\Helper"
--volume "C:\Users\l.nocinski\Source\upgrades\X\24:C:\Run\my\upgrade\License"
--expose 5985
Files in C:\ProgramData\BcContainerHelper\Extensions\X-GOAL\my:
- AdditionalOutput.ps1
- AdditionalSetup.ps1
- HelperFunctions.ps1
- license.bclicense
- MainLoop.ps1
- SetupVariables.ps1
- updatehosts.ps1
Creating container X-GOAL from image mcr.microsoft.com/businesscentral:ltsc2022
cca5976df163c9c871003b3d9bc015e022582cdef22ce22cd429083f88cd4fd7
Waiting for container X-GOAL to be ready
Using artifactUrl https://bcartifacts-exdbf9fwegejdqak.b02.azurefd.net/onprem/24.6.25479.0/ch
Using installer from C:\Run\240
Installing Business Central: multitenant=False, installOnly=False, filesOnly=False, includeTestToolkit=False, includeTestLibrariesOnly=False, includeTestFrameworkOnly=False, includePerformanceToolkit=False, appArtifactPath=c:\dl\onprem\24.6.25479.0\ch, platformArtifactPath=c:\dl\onprem\24.6.25479.0\platform, databasePath=c:\dl\onprem\24.6.25479.0\ch\database\Demo Database BC (24-0).bak, licenseFilePath=c:\dl\onprem\24.6.25479.0\ch\database\Cronus.bclicense, rebootContainer=True
Installing from artifacts
Starting Local SQL Server
Starting Internet Information Server
Copying Service Tier Files
c:\dl\onprem\24.6.25479.0\platform\ServiceTier\Program Files
c:\dl\onprem\24.6.25479.0\platform\ServiceTier\System64Folder
Copying Web Client Files
c:\dl\onprem\24.6.25479.0\platform\WebClient\Microsoft Dynamics NAV
Copying ModernDev Files
c:\dl\onprem\24.6.25479.0\platform
c:\dl\onprem\24.6.25479.0\platform\ModernDev\program files\Microsoft Dynamics NAV
Copying additional files
Copying ConfigurationPackages
C:\dl\onprem\24.6.25479.0\platform\ConfigurationPackages
Copying Test Assemblies
C:\dl\onprem\24.6.25479.0\platform\Test Assemblies
Copying Applications
C:\dl\onprem\24.6.25479.0\ch\Applications
Copying dependencies
Importing PowerShell Modules
Restoring CRONUS Demo Database
Setting CompatibilityLevel for CRONUS on localhost\SQLEXPRESS
Modifying Business Central Service Tier Config File for Docker
Creating Business Central Service Tier
Installing SIP crypto provider: 'C:\Windows\System32\NavSip.dll'
Starting Business Central Service Tier
Importing license file
Stopping Business Central Service Tier
Installation took 117 seconds
Installation complete
Initializing...
Setting host.docker.internal to 10.0.8.145 in container hosts file (copy from host hosts file)
Setting gateway.docker.internal to 10.0.8.145 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.22.32.1 in container hosts file
Starting Container
Hostname is X-GOAL
PublicDnsName is X-GOAL
Using NavUserPassword Authentication
Creating Self Signed Certificate
Self Signed Certificate Thumbprint E65FF80001803B8536F28383CAE49F4E8EB5BEE7
DNS identity X-GOAL
Modifying Service Tier Config File with Instance Specific Settings
Modifying Service Tier Config File with settings from environment variable
Setting ApiServicesEnabled to false
Setting ApiSubscriptionsEnabled to false
Setting BufferedInsertEnabled to true
Setting ClientServicesMaxConcurrentConnections to 2000
Setting DataCacheSize to 12
Setting DisableSmartSql to true
Setting EnableLongRunningSqlStatementsInDebugger to false
Setting EnableSqlInformationDebugger to false
Setting ManagementServicesIdleClientTimeout to 12:00:00
Setting SqlBulkImportBatchSize to 10000
Setting SqlConnectionIdleTimeout to 00:05:00
Setting SqlConnectionTimeout to 00:01:30
Setting SqlLongRunningThreshold to 2000
Creating SqlcontainerParamsByOrdinal and setting it to true
Setting EnableTaskScheduler to False
Starting Service Tier
Registering event sources
Creating DotNetCore Web Server Instance
Using application pool name: BC
Using default container name: NavWebApplicationContainer
Copy files to WWW root C:\inetpub\wwwroot\BC
Create the application pool BC
Create website: NavWebApplicationContainer without SSL
Update configuration: navsettings.json
Done Configuring Web Client
Using license file 'c:\run\my\license.bclicense'
Import License
Creating http download site
Setting SA Password and enabling SA
Creating log as SQL User and add to sysadmin
Creating SUPER user
WARNING: The password that you entered does not meet the minimum requirements.
It should be at least 8 characters long and contain at least one uppercase
letter, one lowercase letter, and one number.

    Directory: C:\Run\my

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d-----        10/21/2024   2:44 PM                upgrade
Enable PSRemoting and setup user for winrm
Allow unencrypted communication to container
Container IP Address: 172.22.35.103
Container Hostname  : X-GOAL
Container Dns Name  : X-GOAL
Web Client          : http://X-GOAL/BC/
Dev. Server         : http://X-GOAL
Dev. ServerInstance : BC
Setting X-GOAL to 172.22.35.103 in host hosts file

Files:
http://X-GOAL:8080/ALLanguage.vsix

Container Total Physical Memory is 63.8Gb
Container Free Physical Memory is 29.9Gb

Initialization took 59 seconds
Ready for connections!
Reading CustomSettings.config from X-GOAL
Creating Desktop Shortcuts for X-GOAL
Cleanup old dotnet core assemblies
Container X-GOAL successfully created

Use:
Get-BcContainerEventLog -containerName X-GOAL to retrieve a snapshot of the event log from the container
Get-BcContainerDebugInfo -containerName X-GOAL to get debug information about the container
Enter-BcContainer -containerName X-GOAL to open a PowerShell prompt inside the container
Remove-BcContainer -containerName X-GOAL to remove the container again
docker logs X-GOAL to retrieve information about URL's again
Loading upgrade configuration inside container ...
Container Powershell version: 7.4.5

WinRM config is

# WinRM Service Starten
Set-Service winrm -StartupType Automatic
Start-Service winrm

# Firewall Ausnahme für WimRM auf Profil Domain setzten
Set-NetFirewallRule -Name WINRM-HTTP-In-TCP-NoScope -Profile Domain -Enabled True
Set-NetFirewallRule -Name WINRM-HTTP-In-TCP -Profile Domain -Enabled True
Set-NetFirewallRule -Name WINRM-HTTP-Compat-In-TCP -Profile Domain -Enabled True

# WinRM Konfigurieren 
# !!! Achtung hier könnte ein Fehler kommen, es funktionierte aber am Ende trotzdem !!!
winrm quickconfig -transport:http

# SSL deaktivieren für container Helper WinRM
Import-Module bccontainerhelper
$bcContainerHelperConfig.useSslForWinRmSession = $false
$bcContainerHelperConfig | ConvertTo-Json | Set-Content "C:\ProgramData\BcContainerHelper\BcContainerHelper.config.json" 
similar-issues-ai[bot] commented 1 day ago

We've found some similar issues:

If any of the above are duplicates, please consider closing this issue out and adding additional context in the original issue.

Note: You can give me feedback by 👍 or 👎 this comment.

freddydk commented 10 hours ago

As a test, could you try to set:

$bcContainerHelperConfig.usePwshForBc24 = $false

and then run the command (you can always set it back to true afterwards)

git-no commented 7 hours ago

@freddydk Thank you Freddy for the quick response.

After setting $bcContainerHelperConfig.usePwshForBc24 = $false and creating a new container the command within the container console

Invoke-NAVApplicationDatabaseConversion -DatabaseServer EXTERNAL -Database b -Credential c

breaks with a new error

Access is denied.

    + CategoryInfo          : NotSpecified: (:) [Invoke-NAVApplicationDatabaseConversion], CryptographicException
    + FullyQualifiedErrorId : System.Security.Cryptography.CryptographicException,Microsoft.Dynamics.Nav.Management.InvokeNAVApplicationDatabaseConversion

Maybe in BC 24 the connection handling to external database server has changed and a regular PS credential ist not enough anymore.

I checked also the PS version within the container. It is now 5.1.20348.2760.

git-no commented 2 hours ago

@freddydk Dear Freddy, I close this ticket. The reason of the issue is not the container helper. Thank you.