Logo Onprem Remote Deploy

Onprem Remote Deploy

Cộng đồng
fernandoartalf
onprem-remote-deploy

AL app deployment to remote Business Central OnPrem servers. Use when deploying .app files from VS Code to a BC server via WinRM, SSH, SMB, or RDP tsclient-pull when network access is restricted.

Tổng quan

Nhà phát hànhfernandoartalf
Kho mãAL-Copilot-Skills-Collection
Tên kỹ năngonprem-remote-deploy
Sao
28
Bản fork
8
Tệp đi kèm
4
Giấy phépMIT
Liên kết
  • Hướng dẫn bằng Markdown

    Tệp SKILL.md được mô hình tải khi cần, nên chỉ tốn token khi có yêu cầu thực sự phù hợp.

  • Dùng được với mọi LLM

    Kỹ năng AI dùng hướng dẫn viết bằng Markdown thay vì mã dành riêng cho một nhà cung cấp, nên dùng được với GPT, Claude, Gemini, Grok hoặc mô hình cục bộ.

  • 4 tệp đi kèm

    Các tập lệnh, mẫu và tài liệu tham khảo mà mô hình có thể đọc khi làm việc. Các tệp chỉ cho phép đọc và không bao giờ được thực thi.

  • Mã nguồn mở

    Được fernandoartalf công bố trên GitHub. Hãy đọc các tệp nguồn trước khi cài đặt.

Cài đặt

Cài đặt kỹ năng AI Onprem Remote Deploy trong TypingMind để dùng với bất kỳ LLM nào, hoặc thêm vào một tác nhân AI khác có thể đọc SKILL.md.

1

Cài đặt trong TypingMind

TypingMind cài đặt kỹ năng trực tiếp từ thư mục GitHub — đọc SKILL.md, đóng gói các tệp tài nguyên và lưu kết quả trên máy.

  1. Mở ứng dụng và vào Plugin → Kỹ năng.
  2. Chọn "Cài đặt từ GitHub".
  3. Dán URL của thư mục kỹ năng được hiển thị bên dưới rồi xác nhận.
    https://github.com/fernandoartalf/AL-Copilot-Skills-Collection/tree/main/skills/onprem-remote-deploy
  4. Bật kỹ năng trong từng cuộc trò chuyện mà bạn muốn sử dụng kỹ năng đó.
Plugin → Kỹ năng → Thêm kỹ năng → Từ URL GitHub, sau đó dán URL thư mục và nhấn Tiếp tục.
2

Cài đặt trong tác nhân AI khác

Bất kỳ tác nhân AI nào đọc được định dạng Agent Skills đều có thể dùng kỹ năng này — hãy sao chép thư mục vào thư mục kỹ năng của tác nhân AI đó.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/fernandoartalf/AL-Copilot-Skills-Collection.git /tmp/AL-Copilot-Skills-Collection
mkdir -p .claude/skills
cp -r /tmp/AL-Copilot-Skills-Collection/skills/onprem-remote-deploy .claude/skills/onprem-remote-deploy
Khởi động lại Claude Code sau khi sao chép để ứng dụng nhận kỹ năng mới.

Sử dụng trong TypingMind

Bật Onprem Remote Deploy trong bất kỳ cuộc trò chuyện nào trên TypingMind, mô hình sẽ tự xử lý phần còn lại. Tên và mô tả của kỹ năng nằm trong prompt hệ thống. Ngay khi có yêu cầu phù hợp, mô hình tự tải toàn bộ hướng dẫn — bạn không cần gọi thủ công và kỹ năng không tốn token cho đến khi thực sự được dùng.

Mô hình tự nạp Onprem Remote Deploy ngay khi có yêu cầu phù hợp.

Dùng được với mọi mô hình AI

Kỹ năng AI là các hướng dẫn Markdown thuần túy, không phải mã dành riêng cho một nhà cung cấp, nên bạn có thể dùng Onprem Remote Deploy với cả những mô hình khác ngoài mô hình ban đầu. Chỉ cần cài đặt một lần trong TypingMind rồi dùng với GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama hoặc mô hình cục bộ do bạn tự chạy — tất cả đều dùng khóa API của riêng bạn.

  • Chỉ tải khi cần

    Prompt hệ thống chỉ chứa tên và mô tả. Hướng dẫn được tải khi có yêu cầu phù hợp đầu tiên, nên khi kỹ năng chưa được dùng, bạn không tốn token cho phần hướng dẫn.

  • Đổi mô hình ngay trong cuộc trò chuyện

    Vì kỹ năng là hướng dẫn chứ không phải mã, việc đổi mô hình không làm kỹ năng ngừng hoạt động — mô hình tiếp theo vẫn đọc cùng tệp SKILL.md.

Hướng dẫn của kỹ năng

Đây là nội dung SKILL.md mà mô hình tải. Hãy đọc trước khi cài đặt — kỹ năng là những hướng dẫn mà mô hình của bạn sẽ làm theo.

Skill: Deploy to BC OnPrem

Purpose

Deploy AL extension .app files from a local VS Code workspace to a remote Business Central OnPrem server. This skill covers multiple deployment strategies ranked by network access level, from fully blocked (tsclient-pull via RDP) to fully open (WinRM/SSH).

When to Load

This skill should be loaded when:

  • A developer needs to publish .app files to a remote BC OnPrem server
  • WinRM, SSH, or SMB access to the server is blocked or restricted
  • A deploy automation script needs to be created or adapted
  • The developer has RDP access to the server but no remote PowerShell access
  • A deploy agent or scheduled task needs to be configured on a BC server

Architecture Overview

The Problem

Deploying AL extensions to BC OnPrem requires running Publish-NAVApp, Sync-NAVApp, and Start-NAVAppDataUpgrade on the server. When the developer's PC cannot reach the server via WinRM (5985), SSH (22), or SMB admin shares (445/d$), traditional push-based deploys fail.

Decision Matrix: Choose Your Strategy

Ask the user these diagnostic questions and select the strategy:

QuestionHow to Test
Can you reach port 5985 (WinRM)?Test-NetConnection -ComputerName <SERVER> -Port 5985
Can you reach port 22 (SSH)?Test-NetConnection -ComputerName <SERVER> -Port 22
Can you reach port 445 (SMB)?Test-NetConnection -ComputerName <SERVER> -Port 445
Can you access \\SERVER\d$?Test-Path "\\<SERVER>\d$"
Are you in the same domain?(Get-WmiObject Win32_ComputerSystem).Domain
Do you have RDP access?User knows this
ScenarioStrategySection
WinRM open (5985) + same domainStrategy A: WinRM DirectSimplest, no agent needed
SSH open (22)Strategy B: SSH DirectNeeds OpenSSH on server
SMB open (445) + admin share or named share worksStrategy C: SMB Push + Remote TriggerGood if auth works
Only RDP access, all other ports blockedStrategy D: tsclient-pull (RDP Agent)Works with zero network access
None of the aboveStrategy E: Manual DeployFallback

Strategy A: WinRM Direct (Best Case)

Requirements: Port 5985 open, same domain or trusted domain, WinRM enabled on server.

Prerequisites (ask server admin)

powershell
# ON THE SERVER (as admin):
Enable-PSRemoting -Force
Set-Item WSMan:\localhost\Client\TrustedHosts -Value "*" -Force   # or specific IPs

Deploy Script Pattern

powershell
param(
    [string]$ServerName,
    [string]$ServerInstance,
    [string]$AppPath,          # local .app file
    [string]$RemotePath,       # path on server to copy to
    [PSCredential]$Credential
)

# 1. Copy .app to server via SMB
$session = New-PSSession -ComputerName $ServerName -Credential $Credential
Copy-Item $AppPath -Destination $RemotePath -ToSession $session

# 2. Execute BC admin commands remotely
Invoke-Command -Session $session -ScriptBlock {
    param($inst, $appPath, $appName, $appVersion, $forceSync)
    Import-Module 'C:\Program Files\Microsoft Dynamics 365 Business Central\*\Service\NavAdminTool.ps1' -DisableNameChecking

    Publish-NAVApp -SkipVerification -ServerInstance $inst -Path $appPath

    if ($forceSync) {
        Sync-NAVApp -ServerInstance $inst -Name $appName -Version $appVersion -Mode ForceSync -Force
    } else {
        Sync-NAVApp -ServerInstance $inst -Name $appName -Version $appVersion
    }

    $current = Get-NAVAppInfo -ServerInstance $inst -Name $appName | 
        Where-Object { $_.Version.ToString() -ne $appVersion } | 
        Sort-Object Version -Descending | Select-Object -First 1
    
    if ($current) {
        Start-NAVAppDataUpgrade -ServerInstance $inst -Name $appName -Version $appVersion
        Unpublish-NAVApp -ServerInstance $inst -Name $appName -Version $current.Version
    } else {
        Install-NAVApp -ServerInstance $inst -Name $appName -Version $appVersion
    }
} -ArgumentList $ServerInstance, $RemotePath, $AppName, $AppVersion, $ForceSync

Remove-PSSession $session

Admin Request Template

We need to enable WinRM on server <SERVER> to deploy Business Central extensions remotely from VS Code. Please run these commands as administrator on the server:

Enable-PSRemoting -Force

Required inbound port: 5985/TCP from the developer network.


Strategy B: SSH Direct

Requirements: Port 22 open, OpenSSH Server installed on the BC server.

Prerequisites (ask server admin)

powershell
# ON THE SERVER (as admin):
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
Start-Service sshd
Set-Service -Name sshd -StartupType Automatic

Deploy Script Pattern

powershell
param(
    [string]$ServerName,
    [string]$User,            # domain\user
    [string]$ServerInstance,
    [string]$LocalAppPath,
    [string]$RemoteAppDir
)

# 1. Copy .app via SCP
$remotePath = "${User}@${ServerName}:${RemoteAppDir}"
scp $LocalAppPath $remotePath

# 2. Execute BC commands via SSH
$appFile = Split-Path $LocalAppPath -Leaf
$remoteFullPath = "$RemoteAppDir\$appFile"

ssh "${User}@${ServerName}" "powershell -ExecutionPolicy Bypass -Command `"
    Import-Module 'C:\Program Files\Microsoft Dynamics 365 Business Central\*\Service\NavAdminTool.ps1' -DisableNameChecking;
    Publish-NAVApp -SkipVerification -ServerInstance '$ServerInstance' -Path '$remoteFullPath';
    Sync-NAVApp -ServerInstance '$ServerInstance' -Name '$AppName' -Version '$AppVersion';
    Start-NAVAppDataUpgrade -ServerInstance '$ServerInstance' -Name '$AppName' -Version '$AppVersion'
`""

Admin Request Template

We need to enable SSH on server <SERVER> to deploy Business Central extensions. Please run these commands as administrator:

Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
Start-Service sshd
Set-Service -Name sshd -StartupType Automatic

Required inbound port: 22/TCP from the developer network.


Strategy C: SMB Push + Remote Trigger

Requirements: Port 445 open, SMB authentication works (same domain or NTLM accepted).

Diagnostic: Why SMB Might Fail

SymptomCauseSolution
Test-Path hangs foreverPC in WORKGROUP, server in domain → NTLM auth hangsUse Strategy D
Error 64 "red no disponible"Admin shares (d$) blocked by GPOCreate a named share
Error 5 "acceso denegado"No permissions on shareAsk admin to grant FullControl
Works with net use but not Test-PathCredential caching issueMap drive first: net use Z: \\server\share /user:domain\user

Create Named Share (on server)

powershell
# ON THE SERVER (as admin):
New-Item -ItemType Directory -Path "D:\BCDeploy" -Force
New-SmbShare -Name "BC_DEPLOY" -Path "D:\BCDeploy" -ChangeAccess "Domain\DeveloperUser"

Deploy Pattern

  1. Copy compiled .app to \\SERVER\BC_DEPLOY\<Entorno>\ via SMB
  2. Copy a trigger script to the same share
  3. A scheduled task on the server detects the trigger and runs the deploy

This is a hybrid of push (files) and pull (execution). If SMB works for files but not for WinRM, this is the best option.


Strategy D: tsclient-pull (RDP Agent) — Zero Network Access

This is the strategy for when EVERYTHING is blocked. Only requires RDP access with drive redirection.

How It Works

┌─────────────────┐                    ┌─────────────────┐
│   Developer PC   │     RDP + drives   │    BC Server     │
│                  │ ──────────────────> │                  │
│ VS Code          │                    │ Scheduled Task   │
│ Deploy script    │                    │ _DeployAgent.ps1 │
│                  │                    │                  │
│ _deploy_output/  │ <── tsclient ───── │ reads trigger    │
│   TRIGGER.txt    │                    │ copies .app      │
│   *.app          │                    │ runs deploy      │
│   RESULT.txt     │ <── writes back ── │ writes result    │
└─────────────────┘                    └─────────────────┘

Flow:

  1. VS Code compiles .app files locally → _deploy_output/<Entorno>/
  2. Creates _DEPLOY_TRIGGER.txt with metadata
  3. Polls for _DEPLOY_RESULT.txt every 5 seconds
  4. Developer connects to server via RDP with drive redirection enabled
  5. Server agent (scheduled task, runs every 1 min) scans \\tsclient\c\...\_deploy_output\ for trigger
  6. Agent reads trigger, copies .app from tsclient to server local disk
  7. Agent executes Publish → Sync → DataUpgrade → Unpublish
  8. Agent writes OK or ERROR to _DEPLOY_RESULT.txt via tsclient
  9. VS Code sees the result → shows LISTO!

RDP Drive Redirection Setup

The developer MUST connect to the server with drive redirection enabled:

Windows Remote Desktop (mstsc.exe):

  1. Open mstsc → "Show Options" / "Mostrar opciones"
  2. Tab "Local Resources" / "Recursos locales"
  3. Click "More..." / "Más..."
  4. Check "Drives" / "Unidades" ✓
  5. Connect

Remote Desktop Manager (RDM):

  1. Right-click connection → Edit / Properties
  2. Section "Local Resources" → "Drives" → Enable ✓
  3. Save and reconnect

Royal TS / mRemoteNG / other RDP clients: Similar option under Local Resources → Drive Redirection.

One-Time Setup: Server Agent

Use the reusable script template in scripts/Setup-DeployAgent.Template.ps1.

  • It uses generic paths and environment names (Entorno1, Entorno2).
  • All script output messages are in English.
  • It creates a scheduled task and an agent script without project-specific names.

For full examples and optional variants, read references/onprem-remote-deploy-reference.md.

Deploy Script (runs on developer PC)

The deploy script on the developer PC performs these steps:

  1. Find alc.exe — searches ~/.vscode/extensions/ms-dynamics-smb.al-*/bin/alc.exe
  2. Bump version — increments 4th component in app.json (e.g., 22.0.8.180 → 22.0.8.181)
  3. Compile — runs alc.exe /project:<AppDir> /packagecachepath:<cache> /out:<output>
  4. Generate server script — creates _RunDeploy_<Entorno>.ps1 with Publish → Sync → DataUpgrade → Unpublish
  5. Write trigger — creates _DEPLOY_TRIGGER.txt with metadata (instance, paths, apps)
  6. Poll for result — checks _DEPLOY_RESULT.txt every 5 seconds, up to 15 minutes

Key parameters:

  • -Entorno Entorno1|Entorno2 — target environment
  • -SoloAppBase — deploy only base app, skip secondary apps
  • -ForzarSync — use Sync-NAVApp -Mode ForceSync -Force (DANGEROUS: can cause data loss)

Trigger format and generated deploy script examples:

See references/onprem-remote-deploy-reference.md for:

  • Trigger file schema (_DEPLOY_TRIGGER.txt)
  • Generated server script pattern (_RunDeploy_<Entorno>.ps1)
  • Generic sample values without customer-specific naming

Compilation: alc.exe Patterns

Finding and running alc.exe

Use the compact patterns in references/onprem-remote-deploy-reference.md:

  • Discover latest alc.exe from AL extension folder
  • Build argument arrays with multiple /assemblyprobingpaths
  • Add extra package cache for dependent apps

Sync Modes: When to Use What

ModeCommandUse WhenRisk
Normal (default)Sync-NAVApp -ServerInstance $inst -Name $name -Version $verRoutine deploys, no breaking schema changesNone — fails safely if incompatible
ForceSyncSync-NAVApp ... -Mode ForceSync -ForceBroken environment, schema pending, destructive schema changesCan delete table data if fields are removed

When the Environment is Broken

Error example (localized): environment requires schema synchronization.

Diagnosis:

powershell
Get-NAVTenant -ServerInstance '<Instance>' | Format-Table Id, State
# If State = "OperationalWithSyncPending" → needs Sync-NAVTenant

Fix:

powershell
Sync-NAVTenant -ServerInstance '<Instance>' -Mode ForceSync -Force

Version Downgrade Error

Error: "Cannot synchronize extension X because a newer version has already been synchronized"

Cause: Server has version N+1, you're trying to deploy version N.

Fix: Bump local version higher than server version, then deploy normally.


Troubleshooting

Common Errors and Solutions

ErrorCauseFix
OperationalWithSyncPendingSync failed mid-deploySync-NAVTenant -Mode ForceSync -Force
newer version has already been synchronizedLocal version < server versionBump local version above server
Cannot upgrade because version must be newerDataUpgrade with same or lower versionBump version, don't downgrade
Trigger not detected by agentDrive redirection not enabled in RDPEnable "Drives" in RDP Local Resources
Test-Path \\server\share hangs foreverPC in WORKGROUP, server in domainUse Strategy D (tsclient-pull)
Agent runs but _DEPLOY_RESULT.txt never appearsScheduled task not runningCheck Task Scheduler, verify user and logon trigger
.Trim() on nullResult file is empty when readAdd null check: if ($raw) { $result = $raw.Trim() }

Diagnostic Commands (run on server)

powershell
# Check all installed apps
Get-NAVAppInfo -ServerInstance '<Instance>' | Sort-Object Name, Version | Format-Table Name, Version, Status -AutoSize

# Check tenant state
Get-NAVTenant -ServerInstance '<Instance>' | Format-Table Id, State

# Check scheduled task
Get-ScheduledTask -TaskName "BC-DeployAgent" | Format-List TaskName, State, LastRunTime, LastTaskResult

# Check if tsclient drives are visible
Test-Path "\\tsclient\c" 
Get-ChildItem "\\tsclient\c" -ErrorAction SilentlyContinue

Customization Checklist

When adapting these scripts for a new project, update:

SettingWhereExample
$ServerInstance / $InstanciaDeploy script paramBC-Entorno1
$environmentsSetup agent script@('Entorno1', 'Entorno2', 'PROD')
$deployBasePathSetup agent scriptD:\BCDeploy
$repoNamesAgent script@('Al_MyProject', 'Al_OtherProject')
$taskUserSetup agent scriptDOMAIN\Username
NavAdminTool pathDeploy script configC:\Program Files\Microsoft Dynamics 365 Business Central\220\Service\NavAdminTool.ps1
ValidateSet for -EntornoDeploy script param'Entorno1', 'Entorno2', 'PROD'
App publisher nameFilename patternMyPublisher
candidatos paths in agentAgent scriptAdd your common repo locations

Security Notes

  • Never use -Mode ForceSync on production without explicit approval — it can delete data from removed table fields
  • The scheduled task runs as the logged-in user with Highest privileges — ensure this is a dedicated service account or trusted admin user
  • Drive redirection (tsclient) is only available during an active RDP session — files are NOT accessible when disconnected
  • The agent does NOT store credentials — it runs in the context of the interactive logon session
  • .app files are copied to a local folder on the server before being published — clean up old .app files periodically

References and Scripts

  • references/onprem-remote-deploy-reference.md: extended examples, trigger schema, and command snippets.
  • scripts/Setup-DeployAgent.Template.ps1: reusable setup script with generic names and English output messages.

Tệp đi kèm

Khi kỹ năng đã được tải, mô hình có thể đọc các tệp này nếu cần. Các tệp này chỉ dùng để đọc và không bao giờ được thực thi.

Câu hỏi thường gặp

Kỹ năng AI Onprem Remote Deploy làm được gì?

AL app deployment to remote Business Central OnPrem servers. Use when deploying .app files from VS Code to a BC server via WinRM, SSH, SMB, or RDP tsclient-pull when network access is restricted.

Vì sao nên dùng Onprem Remote Deploy trên TypingMind?

Vì bạn chỉ cần cài một lần rồi dùng với bất kỳ mô hình nào. Onprem Remote Deploy là nội dung Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên cùng một kỹ năng có thể chạy trên GPT-5, Claude, Gemini, Grok hoặc mô hình trên thiết bị — và bạn có thể đổi mô hình ngay trong cuộc trò chuyện mà kỹ năng vẫn hoạt động. TypingMind dùng khóa API riêng của bạn, nên bạn thanh toán trực tiếp cho nhà cung cấp thay vì trả phí thuê bao theo suất người dùng, đồng thời kỹ năng và các cuộc trò chuyện vẫn nằm trong bộ lưu trữ của bạn.

Làm thế nào để cài Onprem Remote Deploy trong TypingMind?

Mở Plugin → Kỹ năng → Cài đặt từ GitHub trong TypingMind rồi dán https://github.com/fernandoartalf/AL-Copilot-Skills-Collection/tree/main/skills/onprem-remote-deploy. TypingMind đọc tệp SKILL.md, đóng gói các tệp đi kèm rồi cài đặt cả gói dưới dạng một kỹ năng mà bạn có thể bật cho từng cuộc trò chuyện.

Những mô hình AI nào có thể dùng Onprem Remote Deploy?

Bất kỳ mô hình nào bạn kết nối trong TypingMind. Kỹ năng AI là các hướng dẫn bằng Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên GPT, Claude, Gemini, Grok và các mô hình chạy trên thiết bị đều có thể tải kỹ năng này khi có yêu cầu phù hợp.

Có thể dùng Onprem Remote Deploy với bao nhiêu mô hình AI?

Bao nhiêu cũng được. Miễn là mô hình hỗ trợ kỹ năng, bạn có thể dùng Onprem Remote Deploy với mô hình đó — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama và nhiều mô hình khác — tất cả đều trên TypingMind với khóa API riêng của bạn.

Kỹ năng AI Onprem Remote Deploy có miễn phí không?

Có. Kỹ năng này được fernandoartalf phát hành trên GitHub theo giấy phép MIT. Bạn chỉ trả tiền cho nhà cung cấp AI của mình theo số token đã dùng.

Kỹ năng AI là gì?

Kỹ năng AI là một gói hướng dẫn có thể tái sử dụng, chỉ cho mô hình AI cách thực hiện một tác vụ cụ thể. Kỹ năng tuân theo định dạng mở Agent Skills: một tệp SKILL.md chứa tên và mô tả, cùng các tập lệnh, mẫu hoặc tệp tham khảo mà mô hình có thể cần. Mô hình chỉ đọc hướng dẫn khi yêu cầu của bạn phù hợp với kỹ năng, nên kỹ năng đã cài đặt không phát sinh chi phí cho đến khi được sử dụng.

Kỹ năng AI khác gì với plugin hoặc máy chủ MCP?

Plugin hoặc máy chủ MCP cung cấp các công cụ mới mà mô hình có thể gọi. Khi mô hình gọi một công cụ, mã của công cụ đó chạy ở đâu đó và trả về kết quả. Còn kỹ năng AI cung cấp kiến thức và quy trình: cách tiếp cận tác vụ, các bước cần thực hiện và những tiêu chí mà kết quả cần đáp ứng. Kỹ năng chỉ là nội dung Markdown, nên không cần máy chủ, khóa API hay môi trường thực thi và hoạt động với mọi mô hình.

Xem tất cả

Tạo ngay không gian làm việc AI riêng

Đăng ký bản tin của chúng tôi để nhận thông báo về tính năng mới và các đợt tặng quà sắp tới 👇