Modules/businessdev.ALbuild.OnPrem/Public/Publish-BcOnPremContainerApp.ps1
|
function Publish-BcOnPremContainerApp { <# .SYNOPSIS Publishes an AL app to a Business Central server instance running inside a Docker container (licensed). .DESCRIPTION The on-prem counterpart to Publish-BcOnPremApp for deployments where the target BC server runs inside a Docker container on the deployment host (the ALbuild V1 "Release On-Prem" scenario with a container name supplied). The .app is copied into the container and published, synchronised and installed with the in-container BC management cmdlets. Requires Windows + Docker on the agent and a valid ALbuild license. Use Publish-BcOnPremApp when the BC server is installed directly on the host; use this cmdlet when it runs in a container. .PARAMETER ContainerName Name of the Business Central Docker container the app is deployed into. .PARAMETER AppFile Path to the .app file on the host. .PARAMETER SkipVerification Publish without signature verification. .PARAMETER Sync Synchronise after publishing. .PARAMETER Install Install after synchronising. .PARAMETER SyncMode Add (default), Clean, Development or ForceSync. .PARAMETER Scope Global (default) or Tenant. .PARAMETER ServerInstance BC server instance inside the container. Default 'BC'. .PARAMETER Tenant Tenant. Default 'default'. .PARAMETER OperationTimeoutSeconds Maximum seconds to allow each publish/sync/install step before abandoning it and throwing. Default 600. .EXAMPLE Publish-BcOnPremContainerApp -ContainerName 'bcprod' -AppFile .\out\My.app -Sync -Install #> [CmdletBinding(SupportsShouldProcess)] param( [Parameter(Mandatory)] [ValidateNotNullOrEmpty()] [Alias('Name')] [string] $ContainerName, [Parameter(Mandatory)] [string] $AppFile, [switch] $SkipVerification, [switch] $Sync, [switch] $Install, [ValidateSet('Add', 'Clean', 'Development', 'ForceSync')] [string] $SyncMode = 'Add', [ValidateSet('Global', 'Tenant')] [string] $Scope = 'Global', [string] $ServerInstance = 'BC', [string] $Tenant = 'default', [int] $OperationTimeoutSeconds = 600 ) Assert-ALbuildLicensed -Feature 'OnPrem' if (-not (Test-Path -LiteralPath $AppFile)) { throw "App file not found: '$AppFile'." } $leaf = Split-Path -Path $AppFile -Leaf if (-not $PSCmdlet.ShouldProcess($ContainerName, "Publish $leaf")) { return } # Delegate the container copy + publish/sync/install to Publish-BcContainerApp (Apps module). The # licensing gate above is what makes this the on-prem (licensed) deployment surface; the underlying # mechanics are identical to a build-container publish. -WhatIf propagates through the preference # variable, so the callee's own ShouldProcess gate is honoured. $publishArgs = @{ Name = $ContainerName AppFile = $AppFile SyncMode = $SyncMode Scope = $Scope ServerInstance = $ServerInstance Tenant = $Tenant OperationTimeoutSeconds = $OperationTimeoutSeconds } if ($SkipVerification) { $publishArgs['SkipVerification'] = $true } if ($Sync) { $publishArgs['Sync'] = $true } if ($Install) { $publishArgs['Install'] = $true } Publish-BcContainerApp @publishArgs } |