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

Cannot create new BC container with custom server instance name #3569

Closed ernestasjuska closed 5 months ago

ernestasjuska commented 5 months ago

Hello,

In our company we use a shared development server with containers that published on a different ports. To differentiate containers we are using custom server instance names as suggested in https://github.com/microsoft/navcontainerhelper/issues/1429#issuecomment-721154669.

To set custom server instance name we use the following script (commenting out '-myscripts' removes the error):

$artifactUrl2 = Get-BCArtifactUrl -type OnPrem -country w1 -version 24
$ServerInstance = 'bc123'
New-BcContainer `
     -accept_eula -containerName $ServerInstance `
     -artifactUrl $artifactUrl2 `
     -myscripts @(
         @{
             'ServiceSettings.ps1' = @"
 `$NavServiceName = 'MicrosoftDynamicsNavServer`$$ServerInstance'
 `$WebServerInstance = '$ServerInstance'
 `$ServerInstance = '$ServerInstance'
"@
         } ) `
     -auth NavUserPassword `
     -Credential (New-Object -TypeName pscredential -ArgumentList 'user', ('Password1.' | ConvertTo-SecureString -AsPlainText -Force))
Log with -myscripts ```powershell PS C:\Users\ernjus> $artifactUrl2 = Get-BCArtifactUrl -type OnPrem -country w1 -version 24 PS C:\Users\ernjus> $ServerInstance = 'bc123' PS C:\Users\ernjus> New-BcContainer ` >> -accept_eula -containerName $ServerInstance ` >> -artifactUrl $artifactUrl2 ` >> -myscripts @( >> @{ >> 'ServiceSettings.ps1' = @" >> `$NavServiceName = 'MicrosoftDynamicsNavServer`$$ServerInstance' >> `$WebServerInstance = '$ServerInstance' >> `$ServerInstance = '$ServerInstance' >> "@ >> } ) ` >> -auth NavUserPassword ` >> -Credential (New-Object -TypeName pscredential -ArgumentList 'user', ('Password1.' | ConvertTo-SecureString -AsPlainText -Force)) BcContainerHelper is version 6.0.18 BcContainerHelper is not running as administrator Host is Microsoft Windows 11 Enterprise - 10.0.22631.3593 UsePsSession is True UsePwshForBc24 is True UseWinRmSession is allow UseSslForWinRmSession is True Docker Client Version is 26.1.3 Docker Server Version is 26.1.3 Removing Desktop shortcuts Fetching all docker images Fetching all docker volumes Using image mcr.microsoft.com/businesscentral:ltsc2022 Creating Container bc123 Style: onprem Multitenant: No Version: 24.1.18927.19498 Platform: 24.0.19487.0 Generic Tag: 1.0.2.23 Container OS Version: 10.0.20348.2461 (ltsc2022) Host OS Version: 10.0.22631.3593 (23H2) WARNING: Container and host OS build is 20348 or above, defaulting to process isolation. If you encounter issues, you could try to install HyperV. Using process isolation Using locale en-US Disabling the standard eventlog dump to container log every 2 seconds (use -dumpEventLog to enable) Additional Parameters: --expose 5986 Files in C:\ProgramData\BcContainerHelper\Extensions\bc123\my: - AdditionalOutput.ps1 - AdditionalSetup.ps1 - HelperFunctions.ps1 - MainLoop.ps1 - ServiceSettings.ps1 - SetupVariables.ps1 - updatecontainerhosts.ps1 Creating container bc123 from image mcr.microsoft.com/businesscentral:ltsc2022 11a8aef03b7b3d3751164c158fe3092070afa54d6a0746c4acb77d120394f512 Waiting for container bc123 to be ready Using artifactUrl https://bcartifacts-exdbf9fwegejdqak.b02.azurefd.net/onprem/24.1.18927.19498/w1 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.1.18927.19498\w1, platformArtifactPath=c:\dl\onprem\24.1.18927.19498\platform, databasePath=c:\dl\onprem\24.1.18927.19498\w1\database\Demo Database BC (24-0).bak, licenseFilePath=c:\dl\onprem\24.1.18927.19498\w1\database\Cronus.bclicense, rebootContainer=True Installing from artifacts Starting Local SQL Server Starting Internet Information Server Copying Service Tier Files c:\dl\onprem\24.1.18927.19498\platform\ServiceTier\Program Files c:\dl\onprem\24.1.18927.19498\platform\ServiceTier\System64Folder Copying Web Client Files c:\dl\onprem\24.1.18927.19498\platform\WebClient\Microsoft Dynamics NAV Copying ModernDev Files c:\dl\onprem\24.1.18927.19498\platform c:\dl\onprem\24.1.18927.19498\platform\ModernDev\program files\Microsoft Dynamics NAV Copying additional files Copying ConfigurationPackages C:\dl\onprem\24.1.18927.19498\platform\ConfigurationPackages Copying Test Assemblies C:\dl\onprem\24.1.18927.19498\platform\Test Assemblies Copying Applications C:\dl\onprem\24.1.18927.19498\platform\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 An error occurred when creating the WebSocket with the factory of type 'CoreClrClientWebSocketFactory'. See the inner exception for details. at , : line 15 at , : line 1Error Using artifactUrl https://bcartifacts-exdbf9fwegejdqak.b02.azurefd.net/onprem/24.1.18927.19498/w1 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.1.18927.19498\w1, platformArtifactPath=c:\dl\onprem\24.1.18927.19498\platform, databasePath=c:\dl\onprem\24.1.18927.19498\w1\database\Demo Database BC (24-0).bak, licenseFilePath=c:\dl\onprem\24.1.18927.19498\w1\database\Cronus.bclicense, rebootContainer=True Installing from artifacts Starting Local SQL Server Starting Internet Information Server Copying Service Tier Files c:\dl\onprem\24.1.18927.19498\platform\ServiceTier\Program Files c:\dl\onprem\24.1.18927.19498\platform\ServiceTier\System64Folder Copying Web Client Files c:\dl\onprem\24.1.18927.19498\platform\WebClient\Microsoft Dynamics NAV Copying ModernDev Files c:\dl\onprem\24.1.18927.19498\platform c:\dl\onprem\24.1.18927.19498\platform\ModernDev\program files\Microsoft Dynamics NAV Copying additional files Copying ConfigurationPackages C:\dl\onprem\24.1.18927.19498\platform\ConfigurationPackages Copying Test Assemblies C:\dl\onprem\24.1.18927.19498\platform\Test Assemblies Copying Applications C:\dl\onprem\24.1.18927.19498\platform\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 An error occurred when creating the WebSocket with the factory of type 'CoreClrClientWebSocketFactory'. See the inner exception for details. at , : line 15 at , : line 1 New-BcContainer Telemetry Correlation Id: f67a313d-9884-4270-a06a-39327ae73e2b Exception: C:\Users\ernjus\OneDrive - Softera Baltic UAB\Documents\PowerShell\Modules\BcContainerHelper\6.0.18\ContainerHandling\Wait-NavContainerReady.ps1:42 Line | 42 | … throw "Initialization of container $containerName failed" … | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | Initialization of container bc123 failed ```
Log without -myscripts ```powershell PS C:\Users\ernjus> New-BcContainer ` >> -accept_eula -containerName $ServerInstance ` >> -artifactUrl $artifactUrl2 ` >> <# -myscripts @( >> @{ >> 'ServiceSettings.ps1' = @" >> `$NavServiceName = 'MicrosoftDynamicsNavServer`$$ServerInstance' >> `$WebServerInstance = '$ServerInstance' >> `$ServerInstance = '$ServerInstance' >> "@ >> } ) #> ` >> -auth NavUserPassword ` >> -Credential (New-Object -TypeName pscredential -ArgumentList 'user', ('Password1.' | ConvertTo-SecureString -AsPlainText -Force)) BcContainerHelper is version 6.0.18 BcContainerHelper is not running as administrator Host is Microsoft Windows 11 Enterprise - 10.0.22631.3593 UsePsSession is True UsePwshForBc24 is True UseWinRmSession is allow UseSslForWinRmSession is True Docker Client Version is 26.1.3 Docker Server Version is 26.1.3 Removing Session bc123 Removing container bc123 Removing Desktop shortcuts Removing C:\ProgramData\BcContainerHelper\Extensions\bc123 Fetching all docker images Fetching all docker volumes Using image mcr.microsoft.com/businesscentral:ltsc2022 Creating Container bc123 Style: onprem Multitenant: No Version: 24.1.18927.19498 Platform: 24.0.19487.0 Generic Tag: 1.0.2.23 Container OS Version: 10.0.20348.2461 (ltsc2022) Host OS Version: 10.0.22631.3593 (23H2) WARNING: Container and host OS build is 20348 or above, defaulting to process isolation. If you encounter issues, you could try to install HyperV. Using process isolation Using locale en-US Disabling the standard eventlog dump to container log every 2 seconds (use -dumpEventLog to enable) Additional Parameters: --expose 5986 Files in C:\ProgramData\BcContainerHelper\Extensions\bc123\my: - AdditionalOutput.ps1 - AdditionalSetup.ps1 - HelperFunctions.ps1 - MainLoop.ps1 - SetupVariables.ps1 - updatecontainerhosts.ps1 Creating container bc123 from image mcr.microsoft.com/businesscentral:ltsc2022 13a9ba2ea9f48d7e7dec4c7ffd894a58f8ebe72b1506105cc248efd17d43e4e9 Waiting for container bc123 to be ready Using artifactUrl https://bcartifacts-exdbf9fwegejdqak.b02.azurefd.net/onprem/24.1.18927.19498/w1 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.1.18927.19498\w1, platformArtifactPath=c:\dl\onprem\24.1.18927.19498\platform, databasePath=c:\dl\onprem\24.1.18927.19498\w1\database\Demo Database BC (24-0).bak, licenseFilePath=c:\dl\onprem\24.1.18927.19498\w1\database\Cronus.bclicense, rebootContainer=True Installing from artifacts Starting Local SQL Server Starting Internet Information Server Copying Service Tier Files c:\dl\onprem\24.1.18927.19498\platform\ServiceTier\Program Files c:\dl\onprem\24.1.18927.19498\platform\ServiceTier\System64Folder Copying Web Client Files c:\dl\onprem\24.1.18927.19498\platform\WebClient\Microsoft Dynamics NAV Copying ModernDev Files c:\dl\onprem\24.1.18927.19498\platform c:\dl\onprem\24.1.18927.19498\platform\ModernDev\program files\Microsoft Dynamics NAV Copying additional files Copying ConfigurationPackages C:\dl\onprem\24.1.18927.19498\platform\ConfigurationPackages Copying Test Assemblies C:\dl\onprem\24.1.18927.19498\platform\Test Assemblies Copying Applications C:\dl\onprem\24.1.18927.19498\platform\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 183 seconds Installation complete Initializing... Setting host.containerhelper.internal to 172.17.208.1 in container hosts file Starting Container Hostname is bc123 PublicDnsName is bc123 Using NavUserPassword Authentication Creating Self Signed Certificate Self Signed Certificate Thumbprint DECD3767EEAE1879F08F1700527D1FEAF7A58719 DNS identity bc123 Modifying Service Tier Config File with Instance Specific Settings 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 Creating http download site Setting SA Password and enabling SA Creating user as SQL User and add to sysadmin Creating SUPER user Enable PSRemoting and setup user for winrm Creating self-signed certificate for winrm Container IP Address: 172.17.210.133 Container Hostname : bc123 Container Dns Name : bc123 Web Client : http://bc123/BC/ Dev. Server : http://bc123 Dev. ServerInstance : BC Files: http://bc123:8080/ALLanguage.vsix Container Total Physical Memory is 31.7Gb Container Free Physical Memory is 13.4Gb Initialization took 71 seconds Ready for connections! Reading CustomSettings.config from bc123 Creating Desktop Shortcuts for bc123 Cleanup old dotnet core assemblies Container bc123 successfully created Use: Get-BcContainerEventLog -containerName bc123 to retrieve a snapshot of the event log from the container Get-BcContainerDebugInfo -containerName bc123 to get debug information about the container Enter-BcContainer -containerName bc123 to open a PowerShell prompt inside the container Remove-BcContainer -containerName bc123 to remove the container again docker logs bc123 to retrieve information about URL's again ```

BC versions older than 24 show different error but in the same place:

Starting Business Central Service Tier
Importing license file
There was no endpoint listening at http://localhost:7086/bc123/ManagementServicePs/Service.svc that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.
at <ScriptBlock>, C:\Run\navinstall.ps1: line 331
at <ScriptBlock>, C:\Run\start.ps1: line 246
at <ScriptBlock>, <No file>: line 1Error
Using artifactUrl https://bcartifacts-exdbf9fwegejdqak.b02.azurefd.net/onprem/23.7.19495.0/w1

Thanks.

freddydk commented 5 months ago

You should use traefik for this - I don't think you will be able to make this work without.

ernestasjuska commented 5 months ago

I see, thank you.

Traefik does not work for us. We use our AD users for containers and Windows auth only works Traefik "kind of" - there annoying problems, e.g. one user seeing other user's web client, because Traefik ends up using the same connection for both users and IIS does not distinguish beween the two.

Also, Traefik that comes with BcContainerHelper is outdated.

freddydk commented 5 months ago

Yeah, traefik was an open source contribution from a partner - I do not have the time nor insight to upgrade. It works (with username/password) - containers doesn't really work well with windows auth anyway.

The only alternative (I think) would be to publish different port on the host based on which container it is (which I guess is what you are doing)