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

Cannot add duplicate entry name/NavWebClientAppPool #1523

Closed GreatScott000 closed 3 years ago

GreatScott000 commented 3 years ago

PLEASE DO NOT INCLUDE ANY PASSWORDS OR TOKENS IN YOUR ISSUE!!!

Describe the issue Recreating a container to use a new remote SQL server (see #1518) getting an error:

Creating Web Site WARNING: SetupWebClient failed, retrying... Creating Web Site Filename:Error: Cannot add duplicate collection entry of type 'add' with unique key attribute 'name' set to 'NavWebClientAppPool'

Where/why is the duplication happening?

Scripts used to create container and cause the issue


$containerName = 'vect09045'
$password = 'pwd'
$securePassword = ConvertTo-SecureString -String $password -AsPlainText -Force
$credential = New-Object pscredential 'admin', $securePassword
$auth = 'UserPassword'
$artifactUrl = Get-NavArtifactUrl -nav '2016' -cu '45' -country 'gb'
$databaseServer = 'dbserver.containerhelper.internal'
$databaseInstance = ''
$databaseName = 'vect09045'
$databaseUsername = 'Docker'
$databasePassword = 'pwd'
$databaseSecurePassword = ConvertTo-SecureString -String $databasePassword -AsPlainText -Force
$databaseCredential = New-Object pscredential $databaseUsername, $databaseSecurePassword
$licenseFile = 'F:\License\NAV2018License.flf'
New-BcContainer `
    -accept_eula `
    -containerName $containerName `
    -credential $credential `
    -auth $auth `
    -artifactUrl $artifactUrl `
    -databaseServer $databaseServer -databaseInstance $databaseInstance -databaseName $databaseName `
    -databaseCredential $databaseCredential `
    -licenseFile $licenseFile `
    -dns '10.0.1.4' `
    -updateHosts 

#    -myScripts @{ "SetupDatabase.ps1" = "Add-Content -Path 'C:\Windows\System32\drivers\etc\hosts' -Value '$ipaddress $sqlserver'; . 'c:\run\SetupDatabase.ps1'" } `

Full output of scripts

BcContainerHelper is version 1.0.15
BcContainerHelper is running as administrator
Host is Microsoft Windows Server 2019 Datacenter - ltsc2019
Docker Client Version is 19.03.12
Docker Server Version is 19.03.12
Removing container vect09045
Removing vect09045 from host hosts file
Removing vect09045-* from host hosts file
Removing f:\bccontainerhelper\Extensions\vect09045
Fetching all docker images
Using image mcr.microsoft.com/businesscentral:10.0.17763.1577
Creating Container vect09045
Version: 9.0.51476.0-gb
Style: onprem
Multitenant: No
Platform: 9.0.51476.0
Generic Tag: 1.0.1.0
Container OS Version: 10.0.17763.1577 (ltsc2019)
Host OS Version: 10.0.17763.1577 (ltsc2019)
Using process isolation
Using locale en-GB
Disabling the standard eventlog dump to container log every 2 seconds (use -dumpEventLog to enable)
Using license file F:\License\NAV2018License.flf
Files in f:\bccontainerhelper\Extensions\vect09045\my:
- AdditionalOutput.ps1
- license.flf
- MainLoop.ps1
- SetupVariables.ps1
- updatehosts.ps1
Creating container vect09045 from image mcr.microsoft.com/businesscentral:10.0.17763.1577
21793a4bd0c4a1073871cc75357a541ab3dbcc157497179fedd85533fd84eda0
Waiting for container vect09045 to be ready
Using artifactUrl https://bcartifacts.azureedge.net/onprem/9.0.51476.0/gb
Using installer from C:\Run\90
Copying Platform Artifacts
Copying Application Artifacts
Copying Installers
Copying TestToolKit
Copying UpgradeToolKit
Installing NAV
Starting Local SQL Server
Installing Url Rewrite
Installing SQL Clr Types
Installing Report Viewer
Installing OpenXML
Starting Internet Information Server
Copying Service Tier Files
Copying Web Client Files
Copying Windows Client Files
Copying PowerShell Scripts
Copying Test Assemblies
Copying TestToolKit
Copying UpgradeToolKit
Copying ClientUserSettings
Copying ReportBuilder
Skipping restore of Cronus database
Installing C:\NAVDVD\Installers\GB\OlAddin\OutlookAddIn.Local.Gb.msi
Installing C:\NAVDVD\Installers\GB\RTC\RoleTailoredClient.Local.Gb.msi
Installing C:\NAVDVD\Installers\GB\Server\Server.Local.Gb.msi
Installing C:\NAVDVD\Installers\GB\WebClient\WebClient.Local.Gb.msi
Skipping C:\NAVDVD\Installers\GB\WebHelp\WebHelp.Local.Gb.msi
Modifying NAV Service Tier Config File for Docker
Creating NAV Service Tier
Installing SIP crypto provider: 'C:\Windows\System32\NavSip.dll'
Installation took 88 seconds
Installation complete
Initializing...
Setting dbserver.containerhelper.internal to 10.0.1.4 in container hosts file (copy from host hosts file)
Setting host.containerhelper.internal to 172.26.16.1 in container hosts file
Starting Container
Hostname is vect09045
PublicDnsName is vect09045
Using NavUserPassword Authentication
Import Encryption Key
Stopping local SQL Server
Creating Self Signed Certificate
Self Signed Certificate Thumbprint D226F5B6E52C69037F2E97B3B7B2840D3ECE499A
Modifying Service Tier Config File with Instance Specific Settings
Starting Service Tier
Creating Web Site
WARNING: SetupWebClient failed, retrying...
Creating Web Site
Filename: 
Error: Cannot add duplicate collection entry of type 'add' with unique key attribute 'name' set to 'NavWebClientAppPool'

at New-NavWebSite, C:\Run\SetupWebClient.ps1: line 28
at <ScriptBlock>, C:\Run\SetupWebClient.ps1: line 145
at <ScriptBlock>, C:\Run\navstart.ps1: line 174
at <ScriptBlock>, C:\Run\start.ps1: line 350
at <ScriptBlock>, <No file>: line 1Error
Using artifactUrl https://bcartifacts.azureedge.net/onprem/9.0.51476.0/gb
Using installer from C:\Run\90
Copying Platform Artifacts
Copying Application Artifacts
Copying Installers
Copying TestToolKit
Copying UpgradeToolKit
Installing NAV
Starting Local SQL Server
Installing Url Rewrite
Installing SQL Clr Types
Installing Report Viewer
Installing OpenXML
Starting Internet Information Server
Copying Service Tier Files
Copying Web Client Files
Copying Windows Client Files
Copying PowerShell Scripts
Copying Test Assemblies
Copying TestToolKit
Copying UpgradeToolKit
Copying ClientUserSettings
Copying ReportBuilder
Skipping restore of Cronus database
Installing C:\NAVDVD\Installers\GB\OlAddin\OutlookAddIn.Local.Gb.msi
Installing C:\NAVDVD\Installers\GB\RTC\RoleTailoredClient.Local.Gb.msi
Installing C:\NAVDVD\Installers\GB\Server\Server.Local.Gb.msi
Installing C:\NAVDVD\Installers\GB\WebClient\WebClient.Local.Gb.msi
Skipping C:\NAVDVD\Installers\GB\WebHelp\WebHelp.Local.Gb.msi
Modifying NAV Service Tier Config File for Docker
Creating NAV Service Tier
Installing SIP crypto provider: 'C:\Windows\System32\NavSip.dll'
Installation took 88 seconds
Installation complete
Initializing...
Setting dbserver.containerhelper.internal to 10.0.1.4 in container hosts file (copy from host hosts file)
Setting host.containerhelper.internal to 172.26.16.1 in container hosts file
Starting Container
Hostname is vect09045
PublicDnsName is vect09045
Using NavUserPassword Authentication
Import Encryption Key
Stopping local SQL Server
Creating Self Signed Certificate
Self Signed Certificate Thumbprint D226F5B6E52C69037F2E97B3B7B2840D3ECE499A
Modifying Service Tier Config File with Instance Specific Settings
Starting Service Tier
Creating Web Site
WARNING: SetupWebClient failed, retrying...
Creating Web Site
Filename: 
Error: Cannot add duplicate collection entry of type 'add' with unique key attribute 'name' set to 'NavWebClientAppPool'

at New-NavWebSite, C:\Run\SetupWebClient.ps1: line 28
at <ScriptBlock>, C:\Run\SetupWebClient.ps1: line 145
at <ScriptBlock>, C:\Run\navstart.ps1: line 174
at <ScriptBlock>, C:\Run\start.ps1: line 350
at <ScriptBlock>, <No file>: line 1
Initialization of container vect09045 failed
At C:\Program Files\WindowsPowerShell\Modules\BcContainerHelper\1.0.15\ContainerHandling\Wait-NavContainerReady.ps1:43 char:17
+ ...             throw "Initialization of container $containerName failed" ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (Initialization ...ect09045 failed:String) [], RuntimeException
    + FullyQualifiedErrorId : Initialization of container vect09045 failed

Screenshots If applicable, add screenshots to help explain your problem.

Additional context

GreatScott000 commented 3 years ago

Removed the container and reran he script and everything is fine. I wonder what went wrong.

freddydk commented 3 years ago

Sometimes the webclient site generation fails, which is why there is a retry mechanism. In this case that one failed and said it already existed. It isn't something I will pursue any further, but thanks for reporting - if it happens too frequently I might have to dive in again.