feat: Add support to unpublish old and upgraded apps published with Publish-PerTenantExtensionApps #4080
+12
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds a new optional switch parameter unpublishOldVersions to the Publish-PerTenantExtensionApps function that automatically unpublishes old versions of apps after successfully upgrading to a new version. This is mentioned in #2808 and #4046.
Changes
Added unpublishOldVersions switch parameter to function signature
Implemented logic to unpublish old app versions using the Microsoft.NAV.unpublish API endpoint
Added version check to ensure the unpublish API is only called on Business Central versions 25.4.0.0 and later (when the new unpublish API became available)
Updated function documentation to include the new parameter
Technical Details
The unpublish operation only occurs when:
The unpublishOldVersions switch is explicitly provided
An app is being upgraded (not newly installed)
The Business Central version is 25.4.0.0 or later
The upgrade operation completes successfully
Uses the Microsoft.NAV.unpublish API endpoint available in the automation API
Breaking Changes
None - this is an additive change that maintains full backward compatibility.