Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a new Container without starting the BC instance #2905

Closed
DBiernat opened this issue Feb 7, 2023 · 4 comments
Closed

Create a new Container without starting the BC instance #2905

DBiernat opened this issue Feb 7, 2023 · 4 comments
Assignees

Comments

@DBiernat
Copy link

DBiernat commented Feb 7, 2023

Is there a way to create a new container with all required information's but without automatically starting the BC instance?
Before starting the instance we have to run Invoke-NAVApplicationDatabaseConversion on the external database (upgrading from 19 to 20) by using the same container name for both versions.

Script

New-BcContainer -accept_eula `
    -accept_outdated `
    -containerName $containerName `
    -artifactUrl $artifactURL `
    -vsixFile (Get-LatestAlLanguageExtensionUrl) `
    -auth Aad `
    -Credential $credential `
    -authenticationEMail $AadUserName `
    -AadTenant "$($AadUserName.Split('@')[1])" `
    -AadAppId "$($AdProperties.SsoAdAppId)" `
    -AadAppIdUri $appIdUri `
    -alwaysPull `
    -shortcuts None `
    -assignPremiumPlan `
    -isolation process `
    -memoryLimit 6GB `
    -licenseFile $licenseFile `
    -EnableTaskScheduler:$true `
    -additionalParameters $additionalParameters `
    -myScripts $myscripts `
    -dns $dnsServerAddress `
    -useSSL `
    -useTraefik `
    -PublicDnsName $containerPublicDns `
    -databaseServer $databaseServer `
    -databaseInstance $databaseInstance `
    -databaseName $databaseName `
    -databaseCredential $credential

Some output

The Customer database on the DatabaseServer\DatabaseInstance server must be converted by using the Invoke-NAVApplicationDatabaseConversion cmdlet before you can use it with this vers
ion of Dynamics 365 Business Central.
at <ScriptBlock>, C:\Run\SetupDatabase.ps1: line 152
at <ScriptBlock>, C:\Run\navstart.ps1: line 138
at <ScriptBlock>, C:\Run\start.ps1: line 384
at <ScriptBlock>, <No file>: line 1
New-BcContainer Telemetry Correlation Id: 70cd4536-424d-4ad8-8848-fe4e1f3e4cc1
Initialization of container Customer failed
At C:\Program Files\WindowsPowerShell\Modules\BcContainerHelper\4.0.10\ContainerHandling\Wait-NavContainerReady.ps1:42 char:17
+ ...             throw "Initialization of container $containerName failed" ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (Initialization of container GTI failed:String) [], RuntimeException
    + FullyQualifiedErrorId : Initialization of container Customer failed
...

At least for us that would be very useful.

@freddydk
Copy link
Contributor

freddydk commented Feb 7, 2023

On the external database - you can just run the invoke-databaseconversion manually before creating the container - why would you need to do that during startup?
You can also override the SetupDatabase script by adding a file called SetupDatabase.ps1 in the -myscripts parameter.
This new SetupDatabase will be responsible for setting up the database.
It basically needs to do what this section does: https://github.com/microsoft/nav-docker/blob/f6474a40f7d2b6cdb600c51a2f2773d2aba7f369/generic/Run/SetupDatabase.ps1#L135

@DBiernat
Copy link
Author

Back from holiday thanks for the eye opener! ;-)

Sure, downloading the binaries before creating the container and using those PS modules could be a way.
Overriding the SetupDatabase script seems to me the more accurate way. To be honest, I would never have considered it that way.

For me, you could close the issue.

@DobbyNator94
Copy link

Hey, I would like to ask a question about this topic. What is the ideal way to make a new container (maybe BC23) from a BC22 database. Yeah, Invoke-NAVApplicationDatabaseConversion in the SetupDatabase.ps1 is one thing.. But I don‘t find the GitHub issue where someone try‘s to do the same thing but it doesn‘t work anymore (does anyone have the link?), because you must unpublish the apps under BC22 before the invoke. Till a specific time point, the invoke works with apps published with -force. But nowadays that doesn‘t work, because you get problems when you want to sync and publish the new base app. What is the ideal way for this? Would be great if you can carry this extra work with a CMDlet in the BCContainerHelper.

Because the world is not perfect and not every database backup has already unpublished apps. And spinning off an extra BC22 container for unpublishing.. Is a little bit too much. And when you have to do it for a lot of databases..

Thank you very much!

@freddydk
Copy link
Contributor

Sounds like what Kristof is trying to do here as well: #3423
Sure, this might be something one could do in a single cmdlet - but there are just many permutations of options here, not sure I will have time to pursue this,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants