New-BCDevContainer.ps1
# Version 1.0.0.0 function New-BCDevContainer { <# .SYNOPSIS Creates BC container .DESCRIPTION Creates BC container .PARAMETER containerName Name of container .PARAMETER BCLicense The path to the license file .PARAMETER version The version for the artificates to download .PARAMETER sqlBackupfile The file path to the SQL bakcup file .Parameter databaseServer Name of database server when using external SQL Server (omit if using database inside the container) .Parameter databaseInstance Name of database instance when using external SQL Server (omit if using database inside the container) .Parameter databaseName Name of database to connect to when using external SQL Server (omit if using database inside the container) .Parameter includeTestToolkit Specify this parameter to add the test toolkit and the standard tests to the container .Parameter includePerformanceToolkit Include the performance toolkit app (only 17.x and later) .Parameter useTraefik Set the necessary options to make the container work behind a traefik proxy as explained here https://www.axians-infoma.com/techblog/running-multiple-nav-bc-containers-on-an-azure-vm/ .Parameter PublicDnsName Use this parameter to specify which public dns name is pointing to this container. This parameter is necessary if you want to be able to connect to the container from outside the host. .Parameter timeout Specify the number of seconds to wait for activity. Default is 1800 (30 min.). -1 means wait forever. .Parameter enableTaskScheduler Include this switch if you want to do Enable the Task Scheduler .Parameter isolation Isolation mode for the container (default is process isolation if host and container OS match) .Parameter type OnPrem or Sandbox (default is Sandbox) .Parameter useSSL Include this switch if you want to use SSL (https) with a self-signed certificate .Parameter installCertificateOnHost Include this switch if you want to use SSL (https) with a self-signed certificate .EXAMPLE New-BCDevContainer -containerName BCDev -BCLicense "C:\DockerShare\License\BCDev.flf" -version "16.0" .EXAMPLE New-BCDevContainer -containerName BCDev -BCLicense "C:\DockerShare\License\BCDev.flf" -version "16.0" -sqlBackupfile "C:\DockerShare\mssql\Demo Database NAV (11-0).bak" .EXAMPLE New-BCDevContainer -containerName BCDev -BCLicense "C:\DockerShare\License\BCDev.flf" -version "16.0" -includeTestToolkit .EXAMPLE Remember to activate the SQL login for the database server and to active sql login for the sa user New-BCDevContainer -containerName $containerName -version 17.3 -databaseServer 'host.docker.internal' -databaseName 'cronus' Following code might be need to create the user in the database. New-NavContainerNavUser ` -containerName $containerName ` -Credential $credential ` -ChangePasswordAtNextLogOn:$false ` -PermissionSetId SUPER ` -tenant 'Default' #> [CmdletBinding()] param( [string] $containerName = 'bcdev', [string] $bcLicense, [string] $version, [string] $country = 'no', [string] $sqlBackupfile, [string] $databaseServer, [string] $databaseInstance = '', [string] $databaseName, [switch] $includeTestToolkit, [switch] $includePerformanceToolkit, [switch] $includeAL, [switch] $includeCSide, [switch] $doNotExportObjectsToText, [switch] $enableSymbolLoading , [switch] $useTraefik, [string] $PublicDnsName, [switch] $enableTaskScheduler, [ValidateSet('', 'process', 'hyperv')] [string] $isolation = "", [ValidateSet('', 'OnPrem', 'Sandbox')] [string] $type = "OnPrem", [switch] $useSSL = $false, [switch] $installCertificateOnHost = $false, [PSCredential] $credential ) PROCESS { try { $RootDrive = (get-location).Drive.Root $RootFolderPath = join-path $RootDrive 'DockerShare\' $Authentication = 'NavUserPassword' $dbcredentials = New-Object PSCredential -ArgumentList 'sa', $credential.Password $additionalParametersString = '-v ' + $RootFolderPath + ':C:\DockerShare' if ([string]::IsNullOrEmpty($sqlBackupfile)) { $additionalParameters = @(("$additionalParametersString")) } else { $additionalParameters = @(("$additionalParametersString"), ('--env bakfile=' + $sqlBackupfile)) } if ([string]::IsNullOrEmpty($version)) { $artifactUrl = Get-BCArtifactUrl -type:$type -country $country -select Latest } else { $artifactUrl = Get-BCArtifactUrl -type:$type -country $country -version $version -select Latest } if ($useTraefik) { $imageName = $artifactUrl if ($imageName.Contains('https://bcartifacts.azureedge.net')) { $imageName = 'bcimage:' + $imageName.Substring('https://bcartifacts.azureedge.net'.Length + 1).Replace('/', '-') } else { $imageName = 'bcimage:' + $imageName.Substring('https://bcartifacts.blob.core.windows.net'.Length + 1).Replace('/', '-') } } if ([string]::IsNullOrEmpty($databaseName)) { New-BCContainer -isolation:$isolation -accept_eula ` -doNotCheckHealth ` -updateHosts ` -artifactUrl $artifactUrl ` -imageName $imageName ` -containerName $containerName ` -auth $Authentication ` -Credential $credential ` -licenseFile $BCLicense ` -additionalParameters @($additionalParameters) ` -useBestContainerOS ` -includeAL:$includeAL ` -useSSL:$useSSL -installCertificateOnHost:$installCertificateOnHost ` -assignPremiumPlan ` -enableTaskScheduler:$enableTaskScheduler ` -includeTestToolkit:$includeTestToolkit ` -includePerformanceToolkit:$includePerformanceToolkit ` -includeCSide:$includeCSide ` -doNotExportObjectsToText:$doNotExportObjectsToText ` -enableSymbolLoading:$enableSymbolLoading ` -useTraefik:$useTraefik ` -PublicDnsName:$PublicDnsName } else { New-BCContainer -accept_eula ` -doNotCheckHealth ` -updateHosts ` -artifactUrl $artifactUrl ` -imageName $imageName ` -containerName $containerName ` -databaseInstance $databaseInstance ` -databaseServer $databaseServer ` -databaseName $databaseName ` -databaseCredential $dbcredentials ` -auth $Authentication ` -Credential $credential ` -licenseFile $BCLicense ` -additionalParameters @($additionalParameters) ` -useBestContainerOS ` -includeAL:$includeAL ` -useSSL:$useSSL -installCertificateOnHost:$installCertificateOnHost ` -assignPremiumPlan ` -enableTaskScheduler:$enableTaskScheduler ` -includeTestToolkit:$includeTestToolkit ` -includePerformanceToolkit:$includePerformanceToolkit ` -includeCSide:$includeCSide ` -doNotExportObjectsToText:$doNotExportObjectsToText ` -enableSymbolLoading:$enableSymbolLoading ` -useTraefik:$useTraefik ` -PublicDnsName:$PublicDnsName } } catch [Exception] { "New-BCDevContainer :`n`n " + $_.Exception } finally { # Clean up copied backup file after restore completes successfully } } } Export-ModuleMember -Function New-BCDevContainer # SIG # Begin signature block # MIIVlQYJKoZIhvcNAQcCoIIVhjCCFYICAQExCzAJBgUrDgMCGgUAMGkGCisGAQQB # gjcCAQSgWzBZMDQGCisGAQQBgjcCAR4wJgIDAQAABBAfzDtgWUsITrck0sYpfvNR # AgEAAgEAAgEAAgEAAgEAMCEwCQYFKw4DAhoFAAQU62oevng6JBSTbL+hVUDOc1/H # QfagghH1MIIFbzCCBFegAwIBAgIQSPyTtGBVlI02p8mKidaUFjANBgkqhkiG9w0B # AQwFADB7MQswCQYDVQQGEwJH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