Repository navigation
Admin API for PTE publishing/installing for BC29 and later - #2425
spetersenms wants to merge 18 commits into
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
The documentation omits that Scope Dev deployments installing or upgrading PTE dependencies on BC 30+ still require additional Admin Center API authorization and can fail without it.
1 open issue
What changed in this PR
This PR moves AL-Go’s PTE publishing and installation to the Admin Center API for Business Central 30 and later, while preserving legacy publishing for earlier versions.
Changes:
- Adds a shared, version-aware publisher with multipart uploads, operation polling, and bounded retries for transient status failures.
- Routes primary apps and PTE dependencies through the shared publisher and skips explicit old-version cleanup on BC 30+.
- Adds deployment tests and documents authorization requirements and service-managed cleanup.
| File | Description |
|---|---|
| Workshop/ContinuousDeployment.md | Documents authorization and cleanup behavior. |
| Tests/UnpublishOldAppVersions.Test.ps1 | Tests cleanup version boundaries and unknown versions. |
| Tests/PublishPTEApps.Test.ps1 | Tests routing, uploads, polling, and failure handling. |
| Tests/Deploy.Module.Test.ps1 | Tests shared publishing for PTE dependencies. |
| Tests/Deploy.Action.Test.ps1 | Tests action integration and cleanup sequencing. |
| Scenarios/settings.md | Updates deployment authorization and cleanup guidance. |
| Scenarios/RegisterSandboxEnvironment.md | Adds sandbox authorization instructions. |
| Scenarios/RegisterProductionEnvironment.md | Adds production authorization instructions. |
| RELEASENOTES.md | Announces authorization and cleanup changes. |
| Actions/Deploy/README.md | Describes publishing behavior and permissions. |
| Actions/Deploy/Deploy.psm1 | Implements shared publishing and version-aware cleanup. |
| Actions/Deploy/Deploy.ps1 | Uses the shared publisher for primary PTE apps. |
| Actions/.Modules/settings.schema.json | Aligns the cleanup setting description with version-specific behavior. |
Review effort: Balanced
There was a problem hiding this comment.
🟡 Changes recommended
The deployment router can silently query or publish apps against a same-named standard Business Central environment instead of the configured embed target, bypassing fallback and potentially deploying to the wrong environment.
1 open issue
1 resolved since last review
Review effort: Balanced
There was a problem hiding this comment.
🔵 Needs a closer look
Maintainer validation is needed for the live BC29/BC30 upload and operation-response contracts, including authorization, fallback behavior, and service-managed cleanup, because the available tests mock these service boundaries.
No open issues 🎉
1 resolved since last review
Review effort: Balanced
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 8500ace8-7ddb-4aab-9534-7b8d54d2d442
| @@ -1,3 +1,13 @@ | |||
| ### Authorization for PTE deployment on BC 29 and later | |||
There was a problem hiding this comment.
A new version of AL-Go (v10.1) has been released.
Please move your release notes changes to above the ## v10.1 section in the RELEASENOTES.md file.
This ensures your changes are included in the next release rather than being listed under an already-released version.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 8500ace8-7ddb-4aab-9534-7b8d54d2d442
| if ($app -isnot [hashtable]) { | ||
| throw 'Admin Center installed app has missing or invalid identity.' | ||
| } | ||
| $id = if ($app['appId']) { $app['appId'] } else { $app['id'] } |
There was a problem hiding this comment.
Isn't id the true source?
|
|
||
| $installedApps = @($extensions | ForEach-Object { $_ | ConvertTo-HashTable -recurse } | | ||
| Where-Object { $_['isInstalled'] }) | ||
| $applications = @($installedApps | Where-Object { $_['id'] -eq $applicationAppId }) |
There was a problem hiding this comment.
Where does $applicationAppId come from here?
| } | ||
| "pullRequestTrigger" = "pull_request" | ||
| "skipDraftPullRequests" = $false | ||
| "deploymentBaseUrl" = "" |
There was a problem hiding this comment.
Does it make sense to have a complex setting here?
| if ($scope -eq 'Dev' -and $deploymentSettings.DependencyInstallMode -ne 'ignore') { | ||
| foreach ($dependency in $dependencies) { | ||
| $appJson = Get-AppJsonFromAppFile -appFile $dependency | ||
| if ($appJson.idRanges.from -ge 50000 -and $appJson.idRanges.from -lt 100000) { |
There was a problem hiding this comment.
Where does this IDs come from?
|
|
||
| It 'Shares custom target and retained native auth through the exact action imports in a fresh host' { | ||
| $repro = Join-Path $TestDrive 'ActionImports.ps1' | ||
| @' |
There was a problem hiding this comment.
Uff, I am not a fan of long scripts in strings. Any chance to do it differently?
| versionRevision = if ($version) { $version.Revision } else { $null } | ||
| isInstalled = $true | ||
| state = $app['state'] | ||
| publishedAs = $app['appType'] |
| $publishingApi = 'AdminCenter' | ||
| $authorizationDetails = '' | ||
| try { | ||
| $extensions = @(Get-AdminCenterInstalledExtensions -environment $environment) | ||
| } | ||
| catch { | ||
| if (!(Test-AdminCenterAuthorizationError -errorRecord $_)) { throw } | ||
| $authorizationDetails = "$_" | ||
| $publishingApi = 'Automation' | ||
| $extensions = @(GetInstalledExtensions -bcAuthContext $bcAuthContext -environment $environment -publishingApi $publishingApi) | ||
| } | ||
| $applicationVersion = GetPTEApplicationVersion -extensions $extensions -environment $environment |
| Write-Host "Publishing apps using automation API" | ||
| Publish-PerTenantExtensionApps @parameters | ||
| Write-Host "Publishing Per Tenant Extensions" | ||
| PublishPTEApps @parameters |



❔What, Why & How
Moves PTE deployment to the Admin Center API while retaining Automation API compatibility for older environments and deployments without Admin Center authorization. The Automation API's PTE upload endpoint is [deprecated and planned for removal in 2027 release wave 1](https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/administration/resources/dynamics_extensionupload).
Design boundaries
AdminCenterApi.psm1to own the Admin Center API contract, endpoint configuration and authentication context. AL-Go can support the new API without requiring a BCH release.Deploy.psm1: package ordering, installed-version checks, publishing and operation completion. The Admin path preserves BCH's existing behavior of skipping apps already installed at the same or a newer version.API selection
Before PTE publishing, AL-Go makes a read-only Admin request against the configured environment:
The selected path is fixed for the entire Deploy action, including PTE dependencies. Publishing or polling failures never trigger a switch. This avoids mixing deployment APIs and retrying an upload whose outcome may be uncertain. A successful authorization probe does not guarantee installation permission; subsequent failures are reported normally.
Configuration and authentication
deploymentBaseUrlanddeploymentApplicationFamilyconfigure the Admin target independently of BCH settings. They default to the standard Business Central API endpoint andBusinessCentral.AL-Go retains a dedicated Admin authentication context and reuses renewed tokens throughout the run, while leaving BCH's context unchanged. Existing authentication helpers are reused rather than introducing a separate OAuth implementation.
Cleanup
Admin deployments rely on service-managed cleanup. Automation deployments retain the existing optional
unpublishOldVersionsbehavior and its safeguards against removing installed or newer packages.✅ Checklist