Closed ernestasjuska closed 1 year ago
Does this happen every time? The only place, where this module is loaded is inside SetupWebClient.ps1 - in the container. It is never actually loaded on the host...
I could also reproduce it when running as domain user just not running as administator on a different computer.
PS C:\Users\ernjus> Import-Module -Name BcContainerHelper -DisableNameChecking
$ContainerName = 'bcserver'
# You can change this. Get-BCArtifactUrl -type OnPrem -country w1 gives the same error.
$BcArtifactUrl = Get-BCArtifactUrl -type Sandbox -country lt -version 21.5.53619; $BcArtifactUrl
$Credential = New-Object -TypeName pscredential -ArgumentList 'user', ('Password1.' | ConvertTo-SecureString -AsPlainText -Force)
$DatabaseCredential = New-Object -TypeName pscredential -ArgumentList 'sa', ('Password1.' | ConvertTo-SecureString -AsPlainText -Force)
$LicenseFile = 'C:\Users\ernjus\OneDrive - Softera Baltic UAB\Desktop\BC21.bclicense'
$Container = @{
accept_eula = $true
containerName = $ContainerName
isolation = 'hyperv'
updateHosts = $true
artifactUrl = $BcArtifactUrl
auth = 'NavUserPassword'
Credential = $Credential
enableTaskScheduler = $true
#licenseFile = $LicenseFile
}
$Database = @{
multitenant = $true
databaseServer = 'host.containerhelper.internal'
databaseInstance = 'SQL2019DEV'
databasePrefix = "${ContainerName}-"
databaseName = 'app'
databaseCredential = $DatabaseCredential
replaceExternalDatabases = $true
}
New-BcContainer @Container @Database
https://bcartifacts.azureedge.net/sandbox/21.5.53619.56709/lt
BcContainerHelper is version 5.0.2
BcContainerHelper is not running as administrator
UsePsSession is False
Host is Microsoft Windows Server 2019 Standard - 10.0.17763.3887
Docker Client Version is 19.03.5
Docker Server Version is 19.03.5
Removing Desktop shortcuts
Starting Database Restore job from https://bcartifacts.azureedge.net/sandbox/21.5.53619.56709/lt
C:\Program Files\WindowsPowerShell\Modules\BcContainerHelper\5.0.2\Import-BcContainerHelper.ps1
Fetching all docker images
Fetching all docker volumes
Using image mcr.microsoft.com/businesscentral:10.0.17763.3887
Creating Container bcserver
Style: sandbox
Multitenant: Yes
Version: 21.5.53619.56709
Platform: 21.0.53597.56691
Generic Tag: 1.0.2.14
Container OS Version: 10.0.17763.3887 (ltsc2019)
Host OS Version: 10.0.17763.3887 (ltsc2019)
Using hyperv isolation
Using locale
Disabling the standard eventlog dump to container log every 2 seconds (use -dumpEventLog to enable)
Additional Parameters:
--env customNavSettings=EnableTaskScheduler=True
Files in C:\ProgramData\BcContainerHelper\Extensions\bcserver\my:
- AdditionalOutput.ps1
- MainLoop.ps1
- SetupDatabase.ps1
- SetupVariables.ps1
- updatehosts.ps1
Creating container bcserver from image mcr.microsoft.com/businesscentral:10.0.17763.3887
Using Shared Encryption Key file
a5e6ff4096c618ac7f56b6c01bfcd7af2c91aa577e9f6bdd0f0913ed1acfd07f
Waiting for container bcserver to be ready
Using artifactUrl https://bcartifacts.azureedge.net/sandbox/21.5.53619.56709/lt
Using installer from C:\Run\210-new
Installing Business Central
Installing from artifacts
Starting Local SQL Server
WARNING: Waiting for service 'SQL Server (SQLEXPRESS) (MSSQL$SQLEXPRESS)' to
start...
Starting Internet Information Server
Copying Service Tier Files
c:\dl\sandbox\21.5.53619.56709\platform\ServiceTier\Program Files
c:\dl\sandbox\21.5.53619.56709\platform\ServiceTier\System64Folder
Copying PowerShell Scripts
c:\dl\sandbox\21.5.53619.56709\platform\WindowsPowerShellScripts\Cloud\NAVAdministration
c:\dl\sandbox\21.5.53619.56709\platform\WindowsPowerShellScripts\WebSearch
Copying Web Client Files
c:\dl\sandbox\21.5.53619.56709\platform\WebClient\Microsoft Dynamics NAV
Copying ModernDev Files
c:\dl\sandbox\21.5.53619.56709\platform
c:\dl\sandbox\21.5.53619.56709\platform\ModernDev\program files\Microsoft Dynamics NAV
Copying additional files
Copying ConfigurationPackages
C:\dl\sandbox\21.5.53619.56709\platform\ConfigurationPackages
Copying Test Assemblies
C:\dl\sandbox\21.5.53619.56709\platform\Test Assemblies
Copying Extensions
C:\dl\sandbox\21.5.53619.56709\lt\Extensions
Copying Applications
C:\dl\sandbox\21.5.53619.56709\platform\Applications
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 59 seconds
Installation complete
Initializing...
Setting host.containerhelper.internal to 172.18.96.1 in container hosts file
Starting Container
Hostname is bcserver
PublicDnsName is bcserver
Using NavUserPassword Authentication
Error restoring databases. Error was The script 'NAVWebClientManagement.psm1' cannot be run because it contains a "#requires" statement for running as Administrat
or. The current Windows PowerShell session is not running as Administrator. Start Windows PowerShell by using the Run as Administrator option, and then try runni
ng the script again.
at <ScriptBlock>, C:\bcartifacts.cache\sandbox\21.5.53619.56709\platform\ServiceTier\program files\Microsoft Dynamics NAV\210\Service\Microsoft.Dynamics.Nav.Manag
ement.psm1: line 1
at <ScriptBlock>, <No file>: line 28Error
Using artifactUrl https://bcartifacts.azureedge.net/sandbox/21.5.53619.56709/lt
Using installer from C:\Run\210-new
Installing Business Central
Installing from artifacts
Starting Local SQL Server
WARNING: Waiting for service 'SQL Server (SQLEXPRESS) (MSSQL$SQLEXPRESS)' to
start...
Starting Internet Information Server
Copying Service Tier Files
c:\dl\sandbox\21.5.53619.56709\platform\ServiceTier\Program Files
c:\dl\sandbox\21.5.53619.56709\platform\ServiceTier\System64Folder
Copying PowerShell Scripts
c:\dl\sandbox\21.5.53619.56709\platform\WindowsPowerShellScripts\Cloud\NAVAdministration
c:\dl\sandbox\21.5.53619.56709\platform\WindowsPowerShellScripts\WebSearch
Copying Web Client Files
c:\dl\sandbox\21.5.53619.56709\platform\WebClient\Microsoft Dynamics NAV
Copying ModernDev Files
c:\dl\sandbox\21.5.53619.56709\platform
c:\dl\sandbox\21.5.53619.56709\platform\ModernDev\program files\Microsoft Dynamics NAV
Copying additional files
Copying ConfigurationPackages
C:\dl\sandbox\21.5.53619.56709\platform\ConfigurationPackages
Copying Test Assemblies
C:\dl\sandbox\21.5.53619.56709\platform\Test Assemblies
Copying Extensions
C:\dl\sandbox\21.5.53619.56709\lt\Extensions
Copying Applications
C:\dl\sandbox\21.5.53619.56709\platform\Applications
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 59 seconds
Installation complete
Initializing...
Setting host.containerhelper.internal to 172.18.96.1 in container hosts file
Starting Container
Hostname is bcserver
PublicDnsName is bcserver
Using NavUserPassword Authentication
Error restoring databases. Error was The script 'NAVWebClientManagement.psm1' cannot be run because it contains a "#requires" statement for running as Administrat
or. The current Windows PowerShell session is not running as Administrator. Start Windows PowerShell by using the Run as Administrator option, and then try runni
ng the script again.
at <ScriptBlock>, C:\bcartifacts.cache\sandbox\21.5.53619.56709\platform\ServiceTier\program files\Microsoft Dynamics NAV\210\Service\Microsoft.Dynamics.Nav.Manag
ement.psm1: line 1
at <ScriptBlock>, <No file>: line 28
New-BcContainer Telemetry Correlation Id: d55d7f35-7c7f-47cc-8a3c-83dd340cea06
Initialization of container bcserver failed
At C:\Program Files\WindowsPowerShell\Modules\BcContainerHelper\5.0.2\ContainerHandling\Wait-NavContainerReady.ps1:42 char:17
+ ... throw "Initialization of container $containerName failed" ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (Initialization ...bcserver failed:String) [], RuntimeException
+ FullyQualifiedErrorId : Initialization of container bcserver failed
On the machine where it works as administrator - does it then fail as non-admin?
Tried on same machine with same administrator account.
Running in ISE as administrator:
PS C:\Windows\system32> Import-Module -Name BcContainerHelper -DisableNameChecking
$ContainerName = 'bcserver-adm'
# You can change this. Get-BCArtifactUrl -type OnPrem -country w1 gives the same error.
$BcArtifactUrl = Get-BCArtifactUrl -type Sandbox -country lt -version 21.5.53619; $BcArtifactUrl
$Credential = New-Object -TypeName pscredential -ArgumentList 'user', ('Password1.' | ConvertTo-SecureString -AsPlainText -Force)
$DatabaseCredential = New-Object -TypeName pscredential -ArgumentList 'sa', ('Password1.' | ConvertTo-SecureString -AsPlainText -Force)
$LicenseFile = 'C:\Users\ernjus\Desktop\BC21.bclicense'
$Container = @{
accept_eula = $true
containerName = $ContainerName
isolation = 'hyperv'
updateHosts = $true
artifactUrl = $BcArtifactUrl
auth = 'NavUserPassword'
Credential = $Credential
enableTaskScheduler = $true
licenseFile = $LicenseFile
}
$Database = @{
multitenant = $true
databaseServer = 'host.containerhelper.internal'
databaseInstance = 'SQL2019DEV'
databasePrefix = "${ContainerName}-"
databaseName = 'app'
databaseCredential = $DatabaseCredential
replaceExternalDatabases = $true
}
New-BcContainer @Container @Database
BcContainerHelper version 5.0.2
BC.HelperFunctions emits usage statistics telemetry to Microsoft
https://bcartifacts.azureedge.net/sandbox/21.5.53619.56709/lt
BcContainerHelper is version 5.0.2
BcContainerHelper is running as administrator
HyperV is Enabled
UsePsSession is True
Host is Microsoft Windows Server 2019 Standard - 10.0.17763.3887
Docker Client Version is 19.03.5
Docker Server Version is 19.03.5
Removing Desktop shortcuts
Starting Database Restore job from https://bcartifacts.azureedge.net/sandbox/21.5.53619.56709/lt
C:\Program Files\WindowsPowerShell\Modules\BcContainerHelper\5.0.2\Import-BcContainerHelper.ps1
Fetching all docker images
Fetching all docker volumes
Using image mcr.microsoft.com/businesscentral:10.0.17763.3887
Creating Container bcserver-adm
Style: sandbox
Multitenant: Yes
Version: 21.5.53619.56709
Platform: 21.0.53597.56691
Generic Tag: 1.0.2.14
Container OS Version: 10.0.17763.3887 (ltsc2019)
Host OS Version: 10.0.17763.3887 (ltsc2019)
Using hyperv isolation
Using locale
Disabling the standard eventlog dump to container log every 2 seconds (use -dumpEventLog to enable)
Using license file C:\Users\ernjus\Desktop\BC21.bclicense
Additional Parameters:
--env customNavSettings=EnableTaskScheduler=True
Files in C:\ProgramData\BcContainerHelper\Extensions\bcserver-adm\my:
- AdditionalOutput.ps1
- license.bclicense
- MainLoop.ps1
- SetupDatabase.ps1
- SetupVariables.ps1
- updatehosts.ps1
Creating container bcserver-adm from image mcr.microsoft.com/businesscentral:10.0.17763.3887
Using Shared Encryption Key file
8be0308a3426252b9194fb12ae9b81cdeae8f2096632c15b3d4a5a15973b94ef
Waiting for container bcserver-adm to be ready
Using artifactUrl https://bcartifacts.azureedge.net/sandbox/21.5.53619.56709/lt
Using installer from C:\Run\210-new
Installing Business Central
Installing from artifacts
Starting Local SQL Server
WARNING: Waiting for service 'SQL Server (SQLEXPRESS) (MSSQL$SQLEXPRESS)' to
start...
Starting Internet Information Server
Copying Service Tier Files
c:\dl\sandbox\21.5.53619.56709\platform\ServiceTier\Program Files
c:\dl\sandbox\21.5.53619.56709\platform\ServiceTier\System64Folder
Copying PowerShell Scripts
c:\dl\sandbox\21.5.53619.56709\platform\WindowsPowerShellScripts\Cloud\NAVAdministration
c:\dl\sandbox\21.5.53619.56709\platform\WindowsPowerShellScripts\WebSearch
Copying Web Client Files
c:\dl\sandbox\21.5.53619.56709\platform\WebClient\Microsoft Dynamics NAV
Copying ModernDev Files
c:\dl\sandbox\21.5.53619.56709\platform
c:\dl\sandbox\21.5.53619.56709\platform\ModernDev\program files\Microsoft Dynamics NAV
Copying additional files
Copying ConfigurationPackages
C:\dl\sandbox\21.5.53619.56709\platform\ConfigurationPackages
Copying Test Assemblies
C:\dl\sandbox\21.5.53619.56709\platform\Test Assemblies
Copying Extensions
C:\dl\sandbox\21.5.53619.56709\lt\Extensions
Copying Applications
C:\dl\sandbox\21.5.53619.56709\platform\Applications
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 51 seconds
Installation complete
Initializing...
Setting host.containerhelper.internal to 172.18.96.1 in container hosts file
Starting Container
Hostname is bcserver-adm
PublicDnsName is bcserver-adm
Using NavUserPassword Authentication
Success
Import Encryption Key
Stopping local SQL Server
Creating Self Signed Certificate
Self Signed Certificate Thumbprint DDAD9E8DEB1451A14D18A18DFA95159C88F2D7C1
DNS identity bcserver-adm
Modifying Service Tier Config File with Instance Specific Settings
Modifying Service Tier Config File with settings from environment variable
Setting EnableTaskScheduler to True
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
Enabling Financials User Experience
Using license file 'c:\run\my\license.bclicense'
Import License
Creating http download site
Container IP Address: 172.18.99.136
Container Hostname : bcserver-adm
Container Dns Name : bcserver-adm
Web Client : http://bcserver-adm/BC/?tenant=default
Dev. Server : http://bcserver-adm
Dev. ServerInstance : BC
Dev. Server Tenant : default
Setting bcserver-adm to 172.18.99.136 in host hosts file
Files:
http://bcserver-adm:8080/ALLanguage.vsix
WARNING: You are running a container which is 126 days old.
Microsoft recommends that you always run the latest version of our containers.
Container Total Physical Memory is 8.5Gb
Container Free Physical Memory is 6.8Gb
Initialization took 45 seconds
Ready for connections!
Reading CustomSettings.config from bcserver-adm
Creating Desktop Shortcuts for bcserver-adm
Creating Tenant default on bcserver-adm
Copying Database on host.containerhelper.internal\SQL2019DEV from bcserver-adm-tenant to bcserver-adm-default
EngineEdition 3
backup database [bcserver-adm-tenant] to disk = 'C:\Program Files\Microsoft SQL Server\MSSQL15.SQL2019DEV\MSSQL\DATA\bcserveradm\bcserver-adm-tenant.bak' with ini
t, stats=10;
restore database [bcserver-adm-default] from disk = 'C:\Program Files\Microsoft SQL Server\MSSQL15.SQL2019DEV\MSSQL\DATA\bcserveradm\bcserver-adm-tenant.bak' with
stats=10, recovery, move 'Navision_NAV_LT_Data' to 'C:\Program Files\Microsoft SQL Server\MSSQL15.SQL2019DEV\MSSQL\DATA\bcserveradm\bcserver-adm-default.mdf', mo
ve 'Navision_NAV_LT_Log' to 'C:\Program Files\Microsoft SQL Server\MSSQL15.SQL2019DEV\MSSQL\DATA\bcserveradm\bcserver-adm-default.ldf'
Mounting Database for default on server host.containerhelper.internal\SQL2019DEV with AllowAppDatabaseWrite = False
Sync'ing Tenant
Setting bcserver-adm-default to 172.18.99.136 in host hosts file
Setting bcserver-adm-default to 172.18.99.136 in container hosts file
Tenant successfully created
Creating User user
Assigning Permission Set SUPER to user
Container bcserver-adm successfully created
Use:
Get-BcContainerEventLog -containerName bcserver-adm to retrieve a snapshot of the event log from the container
Get-BcContainerDebugInfo -containerName bcserver-adm to get debug information about the container
Enter-BcContainer -containerName bcserver-adm to open a PowerShell prompt inside the container
Remove-BcContainer -containerName bcserver-adm to remove the container again
docker logs bcserver-adm to retrieve information about URL's again
Running in ISE without running as administrator:
PS C:\Users\ernjus> Import-Module -Name BcContainerHelper -DisableNameChecking
$ContainerName = 'bcserver'
# You can change this. Get-BCArtifactUrl -type OnPrem -country w1 gives the same error.
$BcArtifactUrl = Get-BCArtifactUrl -type Sandbox -country lt -version 21.5.53619; $BcArtifactUrl
$Credential = New-Object -TypeName pscredential -ArgumentList 'user', ('Password1.' | ConvertTo-SecureString -AsPlainText -Force)
$DatabaseCredential = New-Object -TypeName pscredential -ArgumentList 'sa', ('Password1.' | ConvertTo-SecureString -AsPlainText -Force)
$LicenseFile = 'C:\Users\ernjus\Desktop\BC21.bclicense'
$Container = @{
accept_eula = $true
containerName = $ContainerName
isolation = 'hyperv'
updateHosts = $true
artifactUrl = $BcArtifactUrl
auth = 'NavUserPassword'
Credential = $Credential
enableTaskScheduler = $true
licenseFile = $LicenseFile
}
$Database = @{
multitenant = $true
databaseServer = 'host.containerhelper.internal'
databaseInstance = 'SQL2019DEV'
databasePrefix = "${ContainerName}-"
databaseName = 'app'
databaseCredential = $DatabaseCredential
replaceExternalDatabases = $true
}
New-BcContainer @Container @Database
BcContainerHelper version 5.0.2
BC.HelperFunctions emits usage statistics telemetry to Microsoft
https://bcartifacts.azureedge.net/sandbox/21.5.53619.56709/lt
BcContainerHelper is version 5.0.2
BcContainerHelper is not running as administrator
UsePsSession is False
Host is Microsoft Windows Server 2019 Standard - 10.0.17763.3887
Docker Client Version is 19.03.5
Docker Server Version is 19.03.5
Removing Session bcserver
Removing container bcserver
Removing entries from hosts
Removing bcserver from container hosts file
Removing bcserver-* from container hosts file
Removing Desktop shortcuts
Removing C:\ProgramData\BcContainerHelper\Extensions\bcserver
Starting Database Restore job from https://bcartifacts.azureedge.net/sandbox/21.5.53619.56709/lt
C:\Program Files\WindowsPowerShell\Modules\BcContainerHelper\5.0.2\Import-BcContainerHelper.ps1
Fetching all docker images
Fetching all docker volumes
Using image mcr.microsoft.com/businesscentral:10.0.17763.3887
Creating Container bcserver
Style: sandbox
Multitenant: Yes
Version: 21.5.53619.56709
Platform: 21.0.53597.56691
Generic Tag: 1.0.2.14
Container OS Version: 10.0.17763.3887 (ltsc2019)
Host OS Version: 10.0.17763.3887 (ltsc2019)
Using hyperv isolation
Using locale
Disabling the standard eventlog dump to container log every 2 seconds (use -dumpEventLog to enable)
Using license file C:\Users\ernjus\Desktop\BC21.bclicense
Additional Parameters:
--env customNavSettings=EnableTaskScheduler=True
Files in C:\ProgramData\BcContainerHelper\Extensions\bcserver\my:
- AdditionalOutput.ps1
- license.bclicense
- MainLoop.ps1
- SetupDatabase.ps1
- SetupVariables.ps1
- updatehosts.ps1
Creating container bcserver from image mcr.microsoft.com/businesscentral:10.0.17763.3887
Using Shared Encryption Key file
c439d1c42cfd5f28578230bab642d74577f3e4e58e6e078dcc964d82d5cee62d
Waiting for container bcserver to be ready
Using artifactUrl https://bcartifacts.azureedge.net/sandbox/21.5.53619.56709/lt
Using installer from C:\Run\210-new
Installing Business Central
Installing from artifacts
Starting Local SQL Server
Starting Internet Information Server
Copying Service Tier Files
c:\dl\sandbox\21.5.53619.56709\platform\ServiceTier\Program Files
c:\dl\sandbox\21.5.53619.56709\platform\ServiceTier\System64Folder
Copying PowerShell Scripts
c:\dl\sandbox\21.5.53619.56709\platform\WindowsPowerShellScripts\Cloud\NAVAdministration
c:\dl\sandbox\21.5.53619.56709\platform\WindowsPowerShellScripts\WebSearch
Copying Web Client Files
c:\dl\sandbox\21.5.53619.56709\platform\WebClient\Microsoft Dynamics NAV
Copying ModernDev Files
c:\dl\sandbox\21.5.53619.56709\platform
c:\dl\sandbox\21.5.53619.56709\platform\ModernDev\program files\Microsoft Dynamics NAV
Copying additional files
Copying ConfigurationPackages
C:\dl\sandbox\21.5.53619.56709\platform\ConfigurationPackages
Copying Test Assemblies
C:\dl\sandbox\21.5.53619.56709\platform\Test Assemblies
Copying Extensions
C:\dl\sandbox\21.5.53619.56709\lt\Extensions
Copying Applications
C:\dl\sandbox\21.5.53619.56709\platform\Applications
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 49 seconds
Installation complete
Initializing...
Setting host.containerhelper.internal to 172.18.96.1 in container hosts file
Starting Container
Hostname is bcserver
PublicDnsName is bcserver
Using NavUserPassword Authentication
Error restoring databases. Error was The script 'NAVWebClientManagement.psm1' cannot be run because it contains a "#requires" statement for running as Administrat
or. The current Windows PowerShell session is not running as Administrator. Start Windows PowerShell by using the Run as Administrator option, and then try runni
ng the script again.
at <ScriptBlock>, C:\bcartifacts.cache\sandbox\21.5.53619.56709\platform\ServiceTier\program files\Microsoft Dynamics NAV\210\Service\Microsoft.Dynamics.Nav.Manag
ement.psm1: line 1
at <ScriptBlock>, <No file>: line 28Error
Using artifactUrl https://bcartifacts.azureedge.net/sandbox/21.5.53619.56709/lt
Using installer from C:\Run\210-new
Installing Business Central
Installing from artifacts
Starting Local SQL Server
Starting Internet Information Server
Copying Service Tier Files
c:\dl\sandbox\21.5.53619.56709\platform\ServiceTier\Program Files
c:\dl\sandbox\21.5.53619.56709\platform\ServiceTier\System64Folder
Copying PowerShell Scripts
c:\dl\sandbox\21.5.53619.56709\platform\WindowsPowerShellScripts\Cloud\NAVAdministration
c:\dl\sandbox\21.5.53619.56709\platform\WindowsPowerShellScripts\WebSearch
Copying Web Client Files
c:\dl\sandbox\21.5.53619.56709\platform\WebClient\Microsoft Dynamics NAV
Copying ModernDev Files
c:\dl\sandbox\21.5.53619.56709\platform
c:\dl\sandbox\21.5.53619.56709\platform\ModernDev\program files\Microsoft Dynamics NAV
Copying additional files
Copying ConfigurationPackages
C:\dl\sandbox\21.5.53619.56709\platform\ConfigurationPackages
Copying Test Assemblies
C:\dl\sandbox\21.5.53619.56709\platform\Test Assemblies
Copying Extensions
C:\dl\sandbox\21.5.53619.56709\lt\Extensions
Copying Applications
C:\dl\sandbox\21.5.53619.56709\platform\Applications
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 49 seconds
Installation complete
Initializing...
Setting host.containerhelper.internal to 172.18.96.1 in container hosts file
Starting Container
Hostname is bcserver
PublicDnsName is bcserver
Using NavUserPassword Authentication
Error restoring databases. Error was The script 'NAVWebClientManagement.psm1' cannot be run because it contains a "#requires" statement for running as Administrat
or. The current Windows PowerShell session is not running as Administrator. Start Windows PowerShell by using the Run as Administrator option, and then try runni
ng the script again.
at <ScriptBlock>, C:\bcartifacts.cache\sandbox\21.5.53619.56709\platform\ServiceTier\program files\Microsoft Dynamics NAV\210\Service\Microsoft.Dynamics.Nav.Manag
ement.psm1: line 1
at <ScriptBlock>, <No file>: line 28
New-BcContainer Telemetry Correlation Id: 12dffaf9-c41c-4ac7-bd82-6b712a04e03a
Initialization of container bcserver failed
At C:\Program Files\WindowsPowerShell\Modules\BcContainerHelper\5.0.2\ContainerHandling\Wait-NavContainerReady.ps1:42 char:17
+ ... throw "Initialization of container $containerName failed" ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (Initialization ...bcserver failed:String) [], RuntimeException
+ FullyQualifiedErrorId : Initialization of container bcserver failed
SetupWebClient.ps1 is not the only place that loads NAVWebClientManagement.psm1. It is imported when importing Microsoft.Dynamics.Nav.Management.psm1. Is there any easy way to get to know which part of code runs <ScriptBlock>, <No file>
?
Ahh - I was only looking for explicit loads. Yes, you are right that the Nav.Management library is probably loaded on the host. Will see what I can do about that
I dug around and it is possible to print scriptblock content from scriptblock itself. Maybe it would be useful to sprinkle these things in the code?
PS C:\Users\ernjus> $A = { write-host '>>>'; write-host $MyInvocation.MyCommand; write-host '<<<' }
PS C:\Users\ernjus> & $A
>>>
write-host '>>>'; write-host $MyInvocation.MyCommand; write-host '<<<'
<<<
These lines cause the Microsoft.Dynamics.Nav.Management.psm1 to load: https://github.com/microsoft/navcontainerhelper/blob/185b6d727c2c6fcd585e66e8e9f7cb44748dca10/Bacpac/Restore-BcDatabaseFromArtifacts.ps1#LL64C1-L84C53
It is a PowerShell job and it runs in host and not in container. It loads Microsoft.Dynamics.Nav.Management to use New-NAVDatabase, Export-NAVApplication, Remove-NAVApplication.
Restore-BcDatabaseFromArtifacts seems to do two things and both run in the container host:
New-NAVDatabase takes file path and according the documentation it only needs to point to the file that SQL server can access so the backup file does not need to be shared with container: https://learn.microsoft.com/en-us/powershell/module/microsoft.dynamics.nav.management/new-navdatabase?view=businesscentral-ps-21
Got it, thanks. Do you know whether this admin check is new for 21.5 - or has this always been like that?
Thanks for the investigations. There are really 5 possible fixes for this:
Remove the dependency on Microsoft.Dynamics.Nav.Management.psm1 form Restore-BcDatabaseFromArtifacts - I won't have the time to rewrite that function, sorry.
Remove the administrator requirement from NAVWebClientManagement.psm1 - I actually think that requirement is there because that module is used to create the Web Site etc, which probably requires this - it would be a bug you need to file on the BC team and I am not sure they would accept this as a bug.
Remove the dependency on NAVWebClientManagement.psm1 from Microsoft.Dynamics.Nav.Management.psm1 - - it would be a bug you need to file on the BC team and I am not sure they would accept this as a bug.
Don't use -replaceExternalDatabases, but instead do things synchronously like this:
Remove-BcDatabase `
-databaseServer $databaseParams.databaseServer `
-databaseInstance $databaseParams.databaseInstance `
-databaseName "$($databaseParams.databasePrefix)%"
Restore-BcDatabaseFromArtifacts `
-artifactUrl $artifactUrl `
-databaseServer $databaseParams.databaseServer `
-databaseInstance $databaseParams.databaseInstance `
-databasePrefix $databaseParams.databasePrefix `
-databaseName $databaseParams.databaseName `
-multitenant:$databaseParams.multitenant
New-BcContainer @databaseParams `
-accept_eula `
-containerName $containerName `
-credential $credential `
-auth $auth `
-artifactUrl $artifactUrl `
-licenseFile $licenseFile `
-updateHosts `
-dns 'hostDNS'
And then you can run the first 2 commands in an elevated PowerShell prompt.
Let's go with 5 - but obviously, you can also do 4. to do things synchronously and remove some of the async magic:-)
I will use 4th for now.
5th has a problem - in onprem\22.1.55890.56216 artifact management module dlls were moved into ...\Service\Management folder. I think better solution would be to use Invoke-ScriptInBcContainer and deal with database restore and splitting from inside of container - it has to be able to access database server so there is no reason to load NAV modules outside the container.
Good point will add this fix as well.
I guess #4 has the same problem with 22.x - should be fixed in the next update
BTW - the reason for doing this outside the container is performance and also, if bakfile is very big (not the cronus) you run into problems in the container.
BTW - the reason for doing this outside the container is performance and also, if bakfile is very big (not the cronus) you run into problems in the container.
Yes, you are right that part does not needed a container. Also that function doesn't even have container parameter so yeah... :) But I still don't like the idea of loading NAV modules outside of docker container.
Well, I respectfully disagree:-) Actually, if you look at the new functions called New-CompilerFolder and Compile-AppWithBcCompilerFolder - then things are going in the direction of doing more things without containers (especially in CI/CD pipelines), but also, restoring a database on a SQL Server on the host really don't need a container.
True, as long as it does not require admin permissions to restore database it counts as a solution to this problem.
Yeah, that one is fixed in the next version.
Shipped in 5.0.3
Hi,
There is an unnecessary administrator check when creating container that uses an external database server. Commenting configuration lines related to database server removes the run as administrator check error. What is weird is that error message is about NAVWebClientManagement.psm1 which should be unrelated.
In our company we are required to have two separate Windows accounts: a domain account without admin permissions and a local admin account. I already ran
Check-BcContainerHelperPermissions -Fix
while in domain account.My guess is that somehow the NAVWebClientManagement.psm1 module is imported not by PowerShell session inside the container but by my domain user that does not have admin permissions so I get the error.
Thanks.
Script used to create the container - uncomment lines in
$Database
to reproduce error:Running with external database:
Running with container database: