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. .PARAMETER Development Publish via the container's development endpoint (like VS Code / BcContainerHelper -useDevEndpoint): the app is published as a replaceable development extension - re-publishable without a version bump, which is what test environments need. Requires -Credential. Ignores -Scope/-Install (the dev endpoint publishes, syncs and installs in one call); -SyncMode maps to the dev schema-update mode. .PARAMETER Credential BC user credential to authenticate to the development endpoint (required with -Development). .EXAMPLE Publish-BcOnPremContainerApp -ContainerName 'bcprod' -AppFile .\out\My.app -Sync -Install .EXAMPLE Publish-BcOnPremContainerApp -ContainerName 'bc-test' -AppFile .\out\My.app -Development -Credential $cred #> [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, [switch] $Development, [pscredential] $Credential ) Assert-ALbuildLicensed -Feature 'OnPrem' if (-not (Test-Path -LiteralPath $AppFile)) { throw "App file not found: '$AppFile'." } if ($Development -and -not $Credential) { throw 'A development (dev-endpoint) publish requires -Credential (the BC user to authenticate to the dev endpoint).' } $leaf = Split-Path -Path $AppFile -Leaf if (-not $PSCmdlet.ShouldProcess($ContainerName, "Publish $leaf")) { return } # Delegate the container copy + publish/sync/install (or the dev-endpoint publish) 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 } if ($Development) { $publishArgs['Development'] = $true; $publishArgs['Credential'] = $Credential } Publish-BcContainerApp @publishArgs } |