Modules/businessdev.ALbuild.Apps/Public/Sync-BcContainerApp.ps1
|
function Sync-BcContainerApp { <# .SYNOPSIS Synchronises a published AL app's schema in a Business Central container. .PARAMETER Name Container name. .PARAMETER AppName The app name. .PARAMETER AppVersion Optional app version. .PARAMETER Mode Schema sync mode: Add (default), Clean, Development or ForceSync. .PARAMETER ServerInstance BC server instance. Default 'BC'. .PARAMETER Tenant Tenant. Default 'default'. .PARAMETER DockerExecutable The Docker executable to use (default 'docker'). #> [CmdletBinding(SupportsShouldProcess)] param( [Parameter(Mandatory)] [Alias('ContainerName')] [string] $Name, [Parameter(Mandatory)] [string] $AppName, [string] $AppVersion, [ValidateSet('Add', 'Clean', 'Development', 'ForceSync')] [string] $Mode = 'Add', [string] $ServerInstance = 'BC', [string] $Tenant = 'default', [string] $DockerExecutable = 'docker' ) if (-not $PSCmdlet.ShouldProcess($Name, "Sync $AppName ($Mode)")) { return } $output = Invoke-BcContainerCommand -ContainerName $Name -DockerExecutable $DockerExecutable -Variables @{ ServerInstance = $ServerInstance; AppName = $AppName; AppVersion = $AppVersion; Mode = $Mode; Tenant = $Tenant } -ScriptBlock { $params = @{ ServerInstance = $ServerInstance; Name = $AppName; Mode = $Mode; Tenant = $Tenant; Force = $true; ErrorAction = 'Stop' } if ($AppVersion) { $params['Version'] = $AppVersion } Sync-NAVApp @params Write-Output "Synchronised $AppName ($Mode)" } Write-ALbuildLog -Level Success ($output.Trim()) } |