microsoft / navcontainerhelper

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

Release pipeline works on BC17.0 - NOT on BC18.0 #1871

Closed TomHedegaardTrimit closed 3 years ago

TomHedegaardTrimit commented 3 years ago

I have a release pipeline which works fine on BC17.0, but when I try to run it on a BC18.0 docker, it fails.

Expected behaviour of the pipeline:

This works fine on a 17.0 docker, but on a 18.0 docker we get this error: The Aggregate Permission Set does not exist. Identification fields and values: Scope='System',App ID='{00000000-0000-0000-0000-000000000000}',Role ID='SUPER'

What is different or changed from 17.0 to 18.0, and do we need to change something in the pipeline script ?

Scripts used to create container and cause the issue

Param(
    [Parameter(Mandatory = $true)]
    [string] $buildProjectFolder,
    [Parameter(Mandatory = $true)]
    [string] $releaseFolder,
    [Parameter(Mandatory = $true)]
    [string] $docFolder,
    [Parameter(Mandatory = $false)]
    [string] $buildArtifactFolder,
    [Parameter(Mandatory = $true)]
    [string] $buildOutputFolder,
    [Parameter(Mandatory = $true)]
    [string] $DockerVersion,
    [Parameter(Mandatory = $true)]
    [string] $buildProjectFolderShopFloor,
    [Parameter(Mandatory = $true)]
    [string] $pipelineScriptFolder
)

$ProgressPreference = "SilentlyContinue"
$username = "TRIMIT"
$password = ConvertTo-SecureString -String "cornator" -Force -AsPlainText
$credential = New-Object PSCredential -ArgumentList $username, $password
$filesPath = "C:\BuildObjects"
$countriesPath = $($filesPath + "\releases")
$containerName = "releasedatabase"

Remove-Item $($releaseFolder) -Force  -Recurse -ErrorAction SilentlyContinue

#TRIMIT
$appjsonPath = Join-Path $buildProjectFolder 'app.json'
$appjson = Get-Content $appjsonPath -Encoding UTF8 | ConvertFrom-Json
$appjson.target = 'OnPrem'
$appjson | ConvertTo-Json | set-content $appjsonPath
$currentVersion = [Version]$appjson.version
$versionTag =  "$($currentVersion.Major).$($currentVersion.Minor).$($currentVersion.Build)"
$fullVersionTag = "$($currentVersion.Major).$($currentVersion.Minor).$($currentVersion.Build).$($currentVersion.MinorRevision)"
Write-Host "TRIMIT vtag says" $versionTag

#TRIMIT Shop Floor
$appjsonPathShopFloor = Join-Path $buildProjectFolderShopFloor 'app.json'
$appjsonShopFloor = Get-Content $appjsonPathShopFloor -Encoding UTF8 | ConvertFrom-Json
$appjsonShopFloor.target = 'OnPrem'
$appjson | ConvertTo-Json | set-content $appjsonPath
$currentVersionShopFloor = [Version]$appjsonShopFloor.version
$versionTagShopFloor =  "$($currentVersionShopFloor.Major).$($currentVersionShopFloor.Minor).$($currentVersionShopFloor.Build)"
$fullVersionTagShopFloor = "$($currentVersionShopFloor.Major).$($currentVersionShopFloor.Minor).$($currentVersionShopFloor.Build).$($currentVersionShopFloor.MinorRevision)"
Write-Host "TRIMIT Shop Floor vtag says" $versionTagShopFloor

#THE - W1 START
$countryW1 = @("W1")
$bakFile = "$filesPath\TRIMIT.bak"
$appNameW1  = "$($appjson.Publisher)_$($appjson.Name)_$($appjson.Version)_$($countryW1).app".Split([System.IO.Path]::GetInvalidFileNameChars()) -join ''
$appNameW1ShopFloor  = "$($appjsonShopFloor.Publisher)_$($appjsonShopFloor.Name)_$($appjsonShopFloor.Version)_$($countryW1).app".Split([System.IO.Path]::GetInvalidFileNameChars()) -join ''

Write-Host "*************************************"
Write-Host "***********creating country $($countryW1) $($appNameW1) & $($appNameW1ShopFloor)**************************"
Write-Host "*************************************"

$releaseFolderCountry = $($releaseFolder + "TRIMIT " + $($versionTag) + "-" + $($countryW1))
$targetSourceFolderW1 = "$releaseFolderCountry\Applications\TRIMIT\Source"
$targetSourceFolderW1ShopFloor = "$releaseFolderCountry\Applications\TRIMITShopFloor\Source"

Remove-Item $($countriesPath + "\" + $countryW1 + "\*.app") -Force  -Recurse -ErrorAction SilentlyContinue
Remove-Item $($countriesPath + "\" + $countryW1 + "\Release\*.*") -Force  -Recurse -ErrorAction SilentlyContinue
Remove-Item $($countriesPath + "\" + $countryW1 + "\ReleaseShopFloor\*.*") -Force  -Recurse -ErrorAction SilentlyContinue

#TRIMIT
Copy-Item $buildProjectFolder"\Layouts" -Destination $targetSourceFolderW1"\TRIMIT.Source\Layouts" -Recurse -Force
Copy-Item $buildProjectFolder"\Logo" -Destination $targetSourceFolderW1"\TRIMIT.Source\Logo" -Recurse -Force
Copy-Item $buildProjectFolder"\src" -Destination $targetSourceFolderW1"\TRIMIT.Source\src" -Recurse -Force
Copy-Item $buildProjectFolder"\Translations" -Destination $targetSourceFolderW1"\TRIMIT.Source\Translations" -Recurse -Force
Copy-Item $buildProjectFolder"\app.json" -Destination $targetSourceFolderW1"\TRIMIT.Source\app.json" -Recurse -Force

Compress-Archive -Path $targetSourceFolderW1"\TRIMIT.Source" -DestinationPath $targetSourceFolderW1"\TRIMIT.Source.zip" -Force
Remove-Item $targetSourceFolderW1"\TRIMIT.Source" -Force  -Recurse -ErrorAction SilentlyContinue

#TRIMIT Shop Floor
Copy-Item $buildProjectFolderShopFloor"\Layouts" -Destination $targetSourceFolderW1ShopFloor"\TRIMITShopFloor.Source\Layouts" -Recurse -Force
Copy-Item $buildProjectFolderShopFloor"\Logo" -Destination $targetSourceFolderW1ShopFloor"\TRIMITShopFloor.Source\Logo" -Recurse -Force
Copy-Item $buildProjectFolderShopFloor"\src" -Destination $targetSourceFolderW1ShopFloor"\TRIMITShopFloor.Source\src" -Recurse -Force
Copy-Item $buildProjectFolderShopFloor"\Translations" -Destination $targetSourceFolderW1ShopFloor"\TRIMITShopFloor.Source\Translations" -Recurse -Force
Copy-Item $buildProjectFolderShopFloor"\app.json" -Destination $targetSourceFolderW1ShopFloor"\TRIMITShopFloor.Source\app.json" -Recurse -Force

Compress-Archive -Path $targetSourceFolderW1ShopFloor"\TRIMITShopFloor.Source" -DestinationPath $targetSourceFolderW1ShopFloor"\TRIMITShopFloor.Source.zip" -Force
Remove-Item $targetSourceFolderW1ShopFloor"\TRIMITShopFloor.Source" -Force  -Recurse -ErrorAction SilentlyContinue

#Release documents
Copy-Item $docFolder"\release\*" -Destination $releaseFolderCountry -Recurse -Force

$BCArtifactUrl = Get-BCArtifactUrl -version $env:DOCKERVERSION -country $countryW1.ToLower() -select Latest
$segments = "$PSScriptRoot".Split('\')
$rootFolder = "$($segments[0])\$($segments[1])"
$additionalParameters = @("--volume ""$($rootFolder):C:\agent""")
New-BCContainer `
    -containerName $containerName `
    -accept_eula `
    -alwaysPull `
    -auth NavUserPassword `
    -Credential $credential `
    -artifactUrl $BCArtifactUrl `
    -licenseFile $env:LICENSE_SECUREFILEPATH `
    -memoryLimit 16G `
    -shortcuts Desktop `
    -useBestContainerOS `
    -updateHosts `
    -doNotExportObjectsToText `
    -doNotCheckHealth `
    -enableTaskScheduler:$false `
    -additionalParameters $additionalParameters `
    -multitenant:$false `
    -bakFile $bakFile

if (-not (test-path $($countriesPath + "\" + $countryW1)))
{
    New-Item -Path $($countriesPath + "\" + $countryW1) -ItemType Directory
}
Copy-FileFromBCContainer -containerName $containerName -localPath $($countriesPath + "\" + $countryW1 + "\System.app") -containerPath 'C:\Program Files\Microsoft Dynamics NAV\180\AL Development Environment\System.app'
Copy-FileFromBCContainer -containerName $containerName -localPath $($countriesPath + "\" + $countryW1 + "\Microsoft_Application.app") -containerPath 'C:\Applications\Application\Source\Microsoft_Application.app'
Copy-FileFromBCContainer -containerName $containerName -localPath $($countriesPath + "\" + $countryW1 + "\Microsoft_Base Application.app") -containerPath 'C:\Applications\BaseApp\Source\Microsoft_Base Application.app'
Copy-FileFromBCContainer -containerName $containerName -localPath $($countriesPath + "\" + $countryW1 + "\Microsoft_System Application.app") -containerPath 'C:\Applications\system application\source\Microsoft_System Application.app'

Write-Host "*************************************"
Write-Host "Compile app on $($countryW1) $($appNameW1) from $($buildProjectFolder) $($buildOutputFolder)"
Write-Host "Compile app on $($countryW1) $($appNameW1ShopFloor) from $($buildProjectFolderShopFloor) $($buildOutputFolder)"
Write-Host "*************************************"

docker exec $containerName powershell Restart-Service -Name 'MicrosoftDynamicsNavServer`$BC'

Clean-BcContainerDatabase -containerName $containerName -saveData
UnInstall-NavContainerApp -containerName $containerName -appName "System Application"
UnPublish-NavContainerApp -containerName $containerName -appName "System Application"
UnPublish-NavContainerApp -containerName $containerName -appName "System"

Publish-NavContainerApp -containerName $containerName -appFile $($countriesPath + "\" + $countryW1 + "\System.app") -packageType SymbolsOnly
Publish-NavContainerApp -containerName $containerName -appFile $($countriesPath + "\" + $countryW1 + "\Microsoft_System Application.app")
Publish-NavContainerApp -containerName $containerName -appFile $($countriesPath + "\" + $countryW1 + "\Microsoft_Base Application.app")
Publish-NavContainerApp -containerName $containerName -appFile $($countriesPath + "\" + $countryW1 + "\Microsoft_Application.app")

Write-Host "*************************************"
invoke-ScriptInBCContainer -containerName $containerName -scriptblock { Sync-NAVTenant BC -Mode ForceSync -Force}
Write-Host "**  sync-NAVTenant  *****************"
Write-Host "*************************************"

Sync-BCContainerApp -containerName $containerName -appName "System Application" -Mode ForceSync -Force
Sync-BCContainerApp -containerName $containerName -appName "Base Application" -Mode ForceSync -Force
Sync-BCContainerApp -containerName $containerName -appName "Application" -Mode ForceSync -Force

Start-NavContainerAppDataUpgrade -containerName $containerName -appName "System Application"
Start-NavContainerAppDataUpgrade -containerName $containerName -appName "Base Application"
Start-NavContainerAppDataUpgrade -containerName $containerName -appName "Application"

Write-Host "*************************************"
invoke-ScriptInBCContainer -containerName $containerName -scriptblock { Restart-NAVServerInstance BC -Force}
Write-Host "**  Restart-NAVServerInstance  ******"
Write-Host "*************************************"

Write-Host "**  check upgrade status  ***********"
invoke-ScriptInBCContainer -containerName $containerName -scriptblock { Get-NAVDataUpgrade BC -Detailed -Force}

Write-Host "**  start Compile  ******************"
Write-Host "*************************************"
#TRIMIT compile
Compile-AppInNavContainer `
-containerName $containerName `
-credential $credential `
-appName $appNameW1 `
-appProjectFolder $buildProjectFolder `
-appOutputFolder $buildOutputFolder | Out-Null

$appFileW1 = Get-ChildItem -Path $buildArtifactFolder -Filter $appNameW1
Write-Host "CodeSigning pfxfile $($pfxFile) target app file $($appFileW1.FullName)"
& $($pipelineScriptFolder + "\CodeSignApps.ps1") -appForCodeSigning $($appFileW1.FullName)
copy-item $appFileW1.FullName -Destination $targetSourceFolderW1
Publish-NavContainerApp -containerName $containerName -appFile $appFileW1.FullName -skipVerification
Write-Host "start synch trimit app version tag $($fullVersionTag)"

Sync-BCContainerApp -containerName $containerName -appName "TRIMIT" -Force -appVersion $fullVersionTag

Start-NavContainerAppDataUpgrade -containerName $containerName -appName "TRIMIT" -appVersion $fullVersionTag
UnInstall-BCContainerApp -containerName $containerName -appName "TRIMIT" -appVersion $fullVersionTag
Install-BCContainerApp -containerName $containerName -appName "TRIMIT" -appVersion $fullVersionTag

#TRIMIT Shop Floor Compile
Compile-AppInNavContainer `
-containerName $containerName `
-credential $credential `
-appName $appNameW1ShopFloor `
-appProjectFolder $buildProjectFolderShopFloor `
-appOutputFolder $buildOutputFolder | Out-Null

$appFileW1ShopFloor = Get-ChildItem -Path $buildArtifactFolder -Filter $appNameW1ShopFloor
Write-Host "CodeSigning pfxfile $($pfxFile) target app file $($appFileW1ShopFloor.FullName)"
& $($pipelineScriptFolder + "\CodeSignApps.ps1") -appForCodeSigning $($appFileW1ShopFloor.FullName)
copy-item $appFileW1ShopFloor.FullName -Destination $targetSourceFolderW1ShopFloor
Publish-NavContainerApp -containerName $containerName -appFile $appFileW1ShopFloor.FullName -skipVerification
Write-Host "start synch trimit app version tag $($fullVersionTagShopFloor)"

Sync-BCContainerApp -containerName $containerName -appName "TRIMIT Shop Floor" -Mode ForceSync -Force -appVersion $fullVersionTagShopFloor
Start-NavContainerAppDataUpgrade -containerName $containerName -appName "TRIMIT Shop Floor" -appVersion $fullVersionTagShopFloor
UnInstall-BCContainerApp -containerName $containerName -appName "TRIMIT Shop Floor" -appVersion $fullVersionTagShopFloor
Install-BCContainerApp -containerName $containerName -appName "TRIMIT Shop Floor" -appVersion $fullVersionTagShopFloor

Invoke-ScriptInBCContainer -containerName $containerName -scriptblock { Remove-NAVServerUser -UserName $using:username -ServerInstance bc -Force }
Backup-NavContainerDatabases -containerName $containerName

if (-not (test-path $($countriesPath + "\" + $countryW1 + "\" + "Release")))
{
    New-Item -Path $($countriesPath + "\" + $countryW1 + "\" + "Release") -ItemType Directory
}
Copy-FileFromBCContainer -containerName $containerName -containerPath C:\ProgramData\BcContainerHelper\Extensions\$containerName\database.bak -localPath $($countriesPath + "\" + $countryW1 + "\" + "Release\TRIMIT-" + $countryW1 + "-" + $versionTag + ".bak")
Remove-NavContainer -containerName $containerName
Copy-Item $($countriesPath + "\" + $countryW1 + "\" + "Release\TRIMIT-" + $countryW1 + "-" + $versionTag + ".bak") -Destination $releaseFolderCountry -Force

Full output of scripts

2021-04-07T08:23:22.5871731Z ##[section]Starting: Create Release Package
2021-04-07T08:23:22.6010366Z ==============================================================================
2021-04-07T08:23:22.6010728Z Task         : PowerShell
2021-04-07T08:23:22.6011147Z Description  : Run a PowerShell script on Linux, macOS, or Windows
2021-04-07T08:23:22.6011428Z Version      : 2.180.1
2021-04-07T08:23:22.6011739Z Author       : Microsoft Corporation
2021-04-07T08:23:22.6012099Z Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/powershell
2021-04-07T08:23:22.6012496Z ==============================================================================
2021-04-07T08:23:23.4934296Z Generating script.
2021-04-07T08:23:23.4981582Z Formatted command: . 'C:\DevOps\Agent_TRIMIT\_work\82\s\DevOps\scripts\CreateMajorReleaseAllCountries.ps1' -buildProjectFolder "C:\DevOps\Agent_TRIMIT\_work\82\s\TRIMIT Base App" -releaseFolder "c:\PipeLine Results\releasepackageMajor211\" -docFolder "c:\BuildObjects\Documentation" -buildArtifactFolder "C:\DevOps\Agent_TRIMIT\_work\82\a\app" -buildOutputFolder "C:\DevOps\Agent_TRIMIT\_work\82\a\app" -DockerVersion "18.0" -buildProjectFolderShopFloor "C:\DevOps\Agent_TRIMIT\_work\82\s\TRIMIT ShopFloor App" -pipelineScriptFolder "C:\DevOps\Agent_TRIMIT\_work\82\s\DevOps\scripts"
2021-04-07T08:23:23.5258639Z ========================== Starting Command Output ===========================
2021-04-07T08:23:23.5458651Z ##[command]"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command ". 'C:\DevOps\Agent_TRIMIT\_work\_temp\bb500b55-a246-48ff-9ab3-5c4681acbe97.ps1'"
2021-04-07T08:23:23.9556714Z TRIMIT vtag says 21.1.2176
2021-04-07T08:23:23.9596619Z TRIMIT Shop Floor vtag says 20.2.1885
2021-04-07T08:23:23.9697876Z *************************************
2021-04-07T08:23:23.9708288Z ***********creating country W1 TRIMIT Development AS_TRIMIT_21.1.2176.1547_W1.app & TRIMIT Development AS_TRIMIT Shop Floor_20.2.1885.1547_W1.app**************************
2021-04-07T08:23:23.9711383Z *************************************
2021-04-07T08:23:50.3362756Z BcContainerHelper version 2.0.10
2021-04-07T08:23:53.9557374Z BcContainerHelper is version 2.0.10
2021-04-07T08:23:53.9564567Z BcContainerHelper is running as ***istrator
2021-04-07T08:23:53.9582510Z Host is Microsoft Windows Server 2019 Standard - ltsc2019
2021-04-07T08:23:54.0895175Z Docker Client Version is 19.03.5
2021-04-07T08:23:54.0917989Z Docker Server Version is 19.03.5
2021-04-07T08:23:54.9208892Z Removing container releasedatabase
2021-04-07T08:23:56.9583511Z Removing releasedatabase from container hosts file
2021-04-07T08:23:57.1148503Z Removing releasedatabase-* from container hosts file
2021-04-07T08:23:57.1678589Z Removing C:\ProgramData\BcContainerHelper\Extensions\releasedatabase
2021-04-07T08:23:57.3016718Z Fetching all docker images
2021-04-07T08:23:57.5208959Z Fetching all docker volumes
2021-04-07T08:23:57.7745915Z Pulling image mcr.microsoft.com/businesscentral:10.0.17763.1757
2021-04-07T08:23:58.2634580Z 10.0.17763.1757: Pulling from businesscentral
2021-04-07T08:23:58.2681338Z Using image mcr.microsoft.com/businesscentral:10.0.17763.1757
2021-04-07T08:23:58.3933143Z Disabling Health Check (always report healthy)
2021-04-07T08:23:58.4151126Z Creating Container releasedatabase
2021-04-07T08:23:58.4158940Z Version: 18.0.23013.24034-W1
2021-04-07T08:23:58.4168140Z Style: sandbox
2021-04-07T08:23:58.4173061Z Multitenant: No
2021-04-07T08:23:58.4180363Z Platform: 18.0.22893.23991
2021-04-07T08:23:58.4197547Z Generic Tag: 1.0.1.4
2021-04-07T08:23:58.4229538Z Container OS Version: 10.0.17763.1757 (ltsc2019)
2021-04-07T08:23:58.4237360Z Host OS Version: 10.0.17763.1757 (ltsc2019)
2021-04-07T08:23:58.4276373Z Using process isolation
2021-04-07T08:23:58.4307968Z Using locale en-US
2021-04-07T08:23:58.4326829Z Disabling the standard eventlog dump to container log every 2 seconds (use -dumpEventLog to enable)
2021-04-07T08:23:58.8635245Z Using license file C:\DevOps\Agent_TRIMIT\_work\_temp\DockerLicense
2021-04-07T08:23:58.9308884Z Additional Parameters:
2021-04-07T08:23:58.9388620Z --volume "C:\DevOps:C:\agent"
2021-04-07T08:23:58.9396563Z --env customNavSettings=EnableTaskScheduler=False
2021-04-07T08:23:58.9404252Z Files in C:\ProgramData\BcContainerHelper\Extensions\releasedatabase\my:
2021-04-07T08:23:58.9491570Z - AdditionalOutput.ps1
2021-04-07T08:23:58.9501278Z - license.flf
2021-04-07T08:23:58.9509633Z - MainLoop.ps1
2021-04-07T08:23:58.9518316Z - SetupVariables.ps1
2021-04-07T08:23:58.9526553Z - updatehosts.ps1
2021-04-07T08:23:58.9534783Z Creating container releasedatabase from image mcr.microsoft.com/businesscentral:10.0.17763.1757
2021-04-07T08:23:59.1280777Z 36b0da53aa099cc87a1b1e9c6e3ef472b293cb8970258b870e83320c152603b9
2021-04-07T08:24:00.9247419Z Waiting for container releasedatabase to be ready
2021-04-07T08:24:04.4984179Z Using artifactUrl https://bcartifacts.azureedge.net/sandbox/18.0.23013.24034/w1
2021-04-07T08:24:04.4987198Z Using installer from C:\Run\150-new
2021-04-07T08:24:04.4987525Z Installing Business Central
2021-04-07T08:24:04.4987737Z Installing from artifacts
2021-04-07T08:24:06.8526868Z Starting Local SQL Server
2021-04-07T08:24:08.0343502Z Starting Internet Information Server
2021-04-07T08:24:08.0345004Z Copying Service Tier Files
2021-04-07T08:24:09.2186892Z Copying PowerShell Scripts
2021-04-07T08:24:09.2187259Z Copying dependencies
2021-04-07T08:24:09.2187443Z Copying ReportBuilder
2021-04-07T08:24:09.2187850Z Importing PowerShell Modules
2021-04-07T08:24:09.2188069Z Skipping restore of Cronus database
2021-04-07T08:24:09.2188377Z Modifying Business Central Service Tier Config File for Docker
2021-04-07T08:24:09.2188680Z Creating Business Central Service Tier
2021-04-07T08:24:33.6400999Z Installing SIP crypto provider: 'C:\Windows\System32\NavSip.dll'
2021-04-07T08:24:33.6401951Z Copying Web Client Files
2021-04-07T08:24:33.6402477Z Copying Client Files
2021-04-07T08:24:33.6402999Z Copying ModernDev Files
2021-04-07T08:24:33.6403532Z Copying additional files
2021-04-07T08:24:33.6404037Z Copying ConfigurationPackages
2021-04-07T08:24:33.6404555Z Copying Test Assemblies
2021-04-07T08:24:33.6405039Z Copying Extensions
2021-04-07T08:24:33.6407665Z Copying Applications
2021-04-07T08:24:33.6410620Z Installation took 29 seconds
2021-04-07T08:24:33.6412507Z Installation complete
2021-04-07T08:24:33.6413107Z Initializing...
2021-04-07T08:24:33.6413625Z Setting host.containerhelper.internal to 172.31.48.1 in container hosts file
2021-04-07T08:24:33.6414133Z Starting Container
2021-04-07T08:24:33.6414562Z Hostname is releasedatabase
2021-04-07T08:24:33.6415016Z PublicDnsName is releasedatabase
2021-04-07T08:24:33.6415479Z Using NavUserPassword Authentication
2021-04-07T08:24:33.6416128Z Using Database .bak file 'C:\ProgramData\BcContainerHelper\Extensions\releasedatabase\database.bak'
2021-04-07T08:24:38.3893033Z Using database server localhost\SQLEXPRESS
2021-04-07T08:24:51.5582293Z Setting CompatibilityLevel for mydatabase on localhost\SQLEXPRESS
2021-04-07T08:24:52.7669391Z Creating Self Signed Certificate
2021-04-07T08:24:52.7670226Z Self Signed Certificate Thumbprint 57CB9E493C9F802ABBEC4D5638F2ED2E529E3F13
2021-04-07T08:24:52.7671006Z Modifying Service Tier Config File with Instance Specific Settings
2021-04-07T08:24:52.7671645Z Modifying Service Tier Config File with settings from environment variable
2021-04-07T08:24:52.7678747Z Setting EnableTaskScheduler to False
2021-04-07T08:28:55.2028512Z Starting Service Tier
2021-04-07T08:28:55.2029724Z Registering event sources
2021-04-07T08:29:32.8836666Z Creating DotNetCore Web Server Instance
2021-04-07T08:29:32.8837626Z Enabling Financials User Experience
2021-04-07T08:29:32.8838240Z Using license file 'c:\run\my\license.flf'
2021-04-07T08:29:32.8838843Z Import License
2021-04-07T08:29:34.0917919Z Creating http download site
2021-04-07T08:29:34.0918698Z Setting SA Password and enabling SA
2021-04-07T08:29:34.0919750Z Creating TRIMIT as SQL User and add to sys***
2021-04-07T08:29:34.0921183Z Creating SUPER user
2021-04-07T08:29:34.0921777Z WARNING: The password that you entered does not meet the minimum requirements. 
2021-04-07T08:29:34.0922526Z It should be at least 8 characters long and contain at least one uppercase 
2021-04-07T08:29:40.2438828Z letter, one lowercase letter, and one number.
2021-04-07T08:29:40.2439625Z The Aggregate Permission Set does not exist. Identification fields and values: Scope='System',App ID='{00000000-0000-0000-0000-000000000000}',Role ID='SUPER'
2021-04-07T08:29:40.2440412Z at <ScriptBlock>, C:\Run\SetupNavUsers.ps1: line 21
2021-04-07T08:29:40.2441074Z at <ScriptBlock>, C:\Run\navstart.ps1: line 202
2021-04-07T08:29:40.2441757Z at <ScriptBlock>, C:\Run\start.ps1: line 363
2021-04-07T08:29:40.2447502Z at <ScriptBlock>, <No file>: line 1Error
2021-04-07T08:29:40.2454016Z Using artifactUrl https://bcartifacts.azureedge.net/sandbox/18.0.23013.24034/w1
2021-04-07T08:29:40.2454474Z Using installer from C:\Run\150-new
2021-04-07T08:29:40.2454737Z Installing Business Central
2021-04-07T08:29:40.2454954Z Installing from artifacts
2021-04-07T08:29:40.2455183Z Starting Local SQL Server
2021-04-07T08:29:40.2455410Z Starting Internet Information Server
2021-04-07T08:29:40.2455647Z Copying Service Tier Files
2021-04-07T08:29:40.2455875Z Copying PowerShell Scripts
2021-04-07T08:29:40.2456165Z Copying dependencies
2021-04-07T08:29:40.2456363Z Copying ReportBuilder
2021-04-07T08:29:40.2456587Z Importing PowerShell Modules
2021-04-07T08:29:40.2456817Z Skipping restore of Cronus database
2021-04-07T08:29:40.2457087Z Modifying Business Central Service Tier Config File for Docker
2021-04-07T08:29:40.2457400Z Creating Business Central Service Tier
2021-04-07T08:29:40.2457699Z Installing SIP crypto provider: 'C:\Windows\System32\NavSip.dll'
2021-04-07T08:29:40.2458232Z Copying Web Client Files
2021-04-07T08:29:40.2458437Z Copying Client Files
2021-04-07T08:29:40.2458624Z Copying ModernDev Files
2021-04-07T08:29:40.2458828Z Copying additional files
2021-04-07T08:29:40.2459011Z Copying ConfigurationPackages
2021-04-07T08:29:40.2459190Z Copying Test Assemblies
2021-04-07T08:29:40.2459382Z Copying Extensions
2021-04-07T08:29:40.2459563Z Copying Applications
2021-04-07T08:29:40.2459772Z Installation took 29 seconds
2021-04-07T08:29:40.2459988Z Installation complete
2021-04-07T08:29:40.2460163Z Initializing...
2021-04-07T08:29:40.2460443Z Setting host.containerhelper.internal to 172.31.48.1 in container hosts file
2021-04-07T08:29:40.2460745Z Starting Container
2021-04-07T08:29:40.2460927Z Hostname is releasedatabase
2021-04-07T08:29:40.2461195Z PublicDnsName is releasedatabase
2021-04-07T08:29:40.2461678Z Using NavUserPassword Authentication
2021-04-07T08:29:40.2462043Z Using Database .bak file 'C:\ProgramData\BcContainerHelper\Extensions\releasedatabase\database.bak'
2021-04-07T08:29:40.2462418Z Using database server localhost\SQLEXPRESS
2021-04-07T08:29:40.2462818Z Setting CompatibilityLevel for mydatabase on localhost\SQLEXPRESS
2021-04-07T08:29:40.2463146Z Creating Self Signed Certificate
2021-04-07T08:29:40.2463486Z Self Signed Certificate Thumbprint 57CB9E493C9F802ABBEC4D5638F2ED2E529E3F13
2021-04-07T08:29:40.2463853Z Modifying Service Tier Config File with Instance Specific Settings
2021-04-07T08:29:40.2464212Z Modifying Service Tier Config File with settings from environment variable
2021-04-07T08:29:40.2464544Z Setting EnableTaskScheduler to False
2021-04-07T08:29:40.2464775Z Starting Service Tier
2021-04-07T08:29:40.2464986Z Registering event sources
2021-04-07T08:29:40.2465228Z Creating DotNetCore Web Server Instance
2021-04-07T08:29:40.2465490Z Enabling Financials User Experience
2021-04-07T08:29:40.2465744Z Using license file 'c:\run\my\license.flf'
2021-04-07T08:29:40.2466004Z Import License
2021-04-07T08:29:40.2466204Z Creating http download site
2021-04-07T08:29:40.2466442Z Setting SA Password and enabling SA
2021-04-07T08:29:40.2467201Z Creating TRIMIT as SQL User and add to sys***
2021-04-07T08:29:40.2467869Z Creating SUPER user
2021-04-07T08:29:40.2468205Z WARNING: The password that you entered does not meet the minimum requirements. 
2021-04-07T08:29:40.2468764Z It should be at least 8 characters long and contain at least one uppercase 
2021-04-07T08:29:40.2469102Z letter, one lowercase letter, and one number.
2021-04-07T08:29:40.2469617Z The Aggregate Permission Set does not exist. Identification fields and values: Scope='System',App ID='{00000000-0000-0000-0000-000000000000}',Role ID='SUPER'
2021-04-07T08:29:40.2470300Z at <ScriptBlock>, C:\Run\SetupNavUsers.ps1: line 21
2021-04-07T08:29:40.2470864Z at <ScriptBlock>, C:\Run\navstart.ps1: line 202
2021-04-07T08:29:40.2471221Z at <ScriptBlock>, C:\Run\start.ps1: line 363
2021-04-07T08:29:40.2471934Z at <ScriptBlock>, <No file>: line 1
2021-04-07T08:29:40.3359247Z Initialization of container releasedatabase failed
2021-04-07T08:29:40.3359912Z At C:\Program Files\WindowsPowerShell\Modules\BcContainerHelper\2.0.10\ContainerHandling\Wait-NavContainerReady.ps1:43 
2021-04-07T08:29:40.3360719Z char:17
2021-04-07T08:29:40.3361002Z + ...             throw "Initialization of container $containerName failed" ...
2021-04-07T08:29:40.3361406Z +                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2021-04-07T08:29:40.3361878Z     + CategoryInfo          : OperationStopped: (Initialization ...database failed:String) [], RuntimeException
2021-04-07T08:29:40.3362372Z     + FullyQualifiedErrorId : Initialization of container releasedatabase failed
2021-04-07T08:29:40.3362659Z  
2021-04-07T08:29:40.4794547Z ##[error]PowerShell exited with code '1'.
2021-04-07T08:29:40.5252656Z ##[section]Finishing: Create Release Package

Additional context

freddydk commented 3 years ago

The permissions system was changed for 18.0 and permissions are now taken from extensions. Since you are using a 16 database, you have the permissions in the database. There is a customconfig setting you can set to use permissions from the database instead of from extensions:

  <add key="UsePermissionsFromExtensions" value="false" />
TomHedegaardTrimit commented 3 years ago

Thanks, But I can only change the customconfig in the container, after the container is generated, and the error I get appears during the New-BCContainer ?
Can I change the config as a parameter at the New-BCContainer command ?

TomHedegaardTrimit commented 3 years ago

@freddydk - can I change the config as a parameter at the New-BCContainer command ?

TGosselink commented 3 years ago

Same issue here.

RemkoD commented 3 years ago

I've the same issue in our build pipeline with BC18. We use BcContainerHelper version 2.0.10. This are our params we pass into New-NavContainer:

Name                           Value                                                                                   
----                           -----                                                                                   
isolation                      process                                                                                 
includeAL                      True                                                                                    
useNewDatabase                 True                                                                                    
artifactUrl                    https://bcartifacts.azureedge.net/onprem/18.0.23013.23795/w1                            
containerName                  c31092                                                                                  
Credential                     System.Management.Automation.PSCredential                                               
additionalParameters           --volume "C:\agents\DOCKERAGENT0114_work\1\s:C:\Source"                                 
accept_eula                    True                                                                                    
accept_outdated                True                                                                                    
auth                           UserPassword                                                                            
imageName                      4ps-bc-18.0-w1                                                                          
licenseFile                    c:\agents\DOCKERAGENT0114_work\_temp\bc18.flf                                           
updateHosts                    True 

This action fails with the following stacktrace:

The Aggregate Permission Set does not exist. Identification fields and values: Scope='System',App ID='{00000000-0000-0000-0000-000000000000}',Role ID='SUPER'
    at <ScriptBlock>, <No file>: line 54
    at Invoke-ScriptInBcContainer, C:\Program Files\WindowsPowerShell\Modules\BcContainerHelper\2.0.10\ContainerHandling\Invoke-ScriptInNavContainer.ps1: line 44
    at New-BcContainerBcUser<Process>, C:\Program Files\WindowsPowerShell\Modules\BcContainerHelper\2.0.10\UserHandling\New-NavContainerNavUser.ps1: line 52
    at Clean-BcContainerDatabase, C:\Program Files\WindowsPowerShell\Modules\BcContainerHelper\2.0.10\AppHandling\Clean-BcContainerDatabase.ps1: line 173
    at New-BcContainer, C:\Program Files\WindowsPowerShell\Modules\BcContainerHelper\2.0.10\ContainerHandling\New-NavContainer.ps1: line 2031 
freddydk commented 3 years ago

You can change a server setting when creating the container using the parameter Tobias described here: https://github.com/microsoft/navcontainerhelper/issues/1881

TGosselink commented 3 years ago

Thanks Freddy. I tried issue 1881 "-e customNavSettings=UsePermissionsFromExtensions=false" I combined it with useNewDatabase = $true

Result is the same:

Importing License C:\Run\my\license.flf
Creating user admin
Creating User admin
Assigning Permission Set SUPER to admin
**Aggregate Permission Set does not exist. Identification fields and values: Scope='System',App ID='{00000000-0000-0000-0000-000000000000}',Role ID='SUPER'**
at <ScriptBlock>, <No file>: line 54
at Invoke-ScriptInBcContainer, C:\Program Files\WindowsPowerShell\Modules\BcContainerHelper\2.0.10\ContainerHandling\Invoke-ScriptInNavContainer.ps1: line 44
at New-BcContainerBcUser<Process>, C:\Program Files\WindowsPowerShell\Modules\BcContainerHelper\2.0.10\UserHandling\New-NavContainerNavUser.ps1: line 52
at Clean-BcContainerDatabase, C:\Program Files\WindowsPowerShell\Modules\BcContainerHelper\2.0.10\AppHandling\Clean-BcContainerDatabase.ps1: line 173
at New-BcContainer, C:\Program Files\WindowsPowerShell\Modules\BcContainerHelper\2.0.10\ContainerHandling\New-NavContainer.ps1: line 2031
at <ScriptBlock>, D:\PreReq\BC\BC_Docker_requirements\Scripts\Setup-Container.ps1: line 547
at <ScriptBlock>, C:\azagent\A1\_work\_temp\7a84c46f-21cd-4483-a027-cf87d20a593c.ps1: line 3
at <ScriptBlock>, <No file>: line 1

Failed creating a new Container.

So the problem remains unfortunatelly

freddydk commented 3 years ago

Post the full output, then we can see whether the setting was applied or what goes wrong. Thanks

KristofKlein commented 3 years ago

Hi, we also struggle with this. We applied the workaround with the UsePermissionsFromExtensions = false. (like -additionalParameters @("-e customNavSettings=UsePermissionsFromExtensions=false") ) and it does something to the execution as the point of failing moved. without the additional Paramter it died right after "Removing Database CRONUS" while with it dies at: Creating User xxx Assign Permission Set SUPER to xxx We also work with newDatabase (due to customized Base app development).

freddydk commented 3 years ago

Please post the full output or even better email me a link to a .zip file, which includes script + bak file so that I can repro. Then I will fix this asap.

KristofKlein commented 3 years ago

Well, no bak file! it is as simple as just calling New-BCContainer like the following on your machine (mind the license !):

New-BCContainer -accept_eula `
    -containerName "BC18X" `
    -artifactUrl (Get-BCArtifactUrl -type OnPrem -version 18 -country w1) `
    -auth Windows `
    -updateHosts `
    -isolation hyperv `
    -licenseFile "N:\Developerlicense\license.flf" `
    -memoryLimit 12G `
    -useNewDatabase

it runs fine until it hits:

(...) Initialization took 37 seconds Ready for connections! Reading CustomSettings.config from BC18X Creating Desktop Shortcuts for BC18X Stopping ServiceTier in order to replace database Copying Database on localhost\SQLEXPRESS from CRONUS to mytempdb Taking database CRONUS offline Copying database files Attaching files as new Database mytempdb Putting database CRONUS back online Removing Database CRONUS from localhost\SQLEXPRESS Creating new database CRONUS on localhost\SQLEXPRESS with Collation Latin1_General_100_CSAS Copying table [Entitlement] from original database Copying table [Entitlement Set] from original database Copying table [Membership Entitlement] from original database Removing Database mytempdb from localhost\SQLEXPRESS Starting Service Tier Synchronizing Importing license file Importing License C:\Run\my\license.flf Creating user kleink The Aggregate Permission Set does not exist. Identification fields and values: Scope='System',App ID='{00000000-0000-0000-0000-000000000000}',Role ID='SUPER' at , : line 3 at Invoke-ScriptInBcContainer, C:\Program Files\WindowsPowerShell\Modules\BcContainerHelper\2.0.10\ContainerHandling\Invoke-ScriptInNavContainer.ps1: line 44 at Clean-BcContainerDatabase, C:\Program Files\WindowsPowerShell\Modules\BcContainerHelper\2.0.10\AppHandling\Clean-BcContainerDatabase.ps1: line 166 at New-BcContainer, C:\Program Files\WindowsPowerShell\Modules\BcContainerHelper\2.0.10\ContainerHandling\New-NavContainer.ps1: line 2031 at , : line 1 The Aggregate Permission Set does not exist. Identification fields and values: Scope='System',App ID='{00000000-0000-0000-0000-000000000000}',Rol e ID='SUPER' At C:\Program Files\WindowsPowerShell\Modules\BcContainerHelper\2.0.10\ContainerHandling\Invoke-ScriptInNavContainer.ps1:45 char:13 '+ throw $.Exception.Message '+ ~~~~~~ '+ CategoryInfo : OperationStopped: (The Aggregate P...Role ID='SUPER':String) [], RuntimeException '+ FullyQualifiedErrorId : The Aggregate Permission Set does not exist. Identification fields and values: Scope='System',App ID='{00000000-00
00-0000-0000-000000000000}',Role ID='SUPER'

KristofKlein commented 3 years ago

Once again it might be a simple spello...

it is not -additionalParameters @("-e customNavSettings=UsePermissionsFromExtensions=false") but -additionalParameters @("-e customNavSettings=UsePermissionSetsFromExtensions=false") ...i'll keep you updated ....

KristofKlein commented 3 years ago

I think this helps! (getting at least a different error now...)