microsoft / navcontainerhelper

Official Microsoft repository for BcContainerHelper, a PowerShell module, which makes it easier to work with Business Central Containers on Docker.
MIT License
376 stars 243 forks source link

Ability to unpublish specific version number of an extension in a SaaS environment #2808

Open scm6iwa opened 1 year ago

scm6iwa commented 1 year ago

This isn't an issue but more of a request.

Could you create a Unpublish-PerTenantExtensionApps script where you can unpublish specific versions of an extension in a BCSaaS environment.

This would be useful so when I publish an extension using Publish-PerTenantExtensionApps to my SaaS sandboxes via my pipeline's I can then also unpublish the uninstalled extensions to keep the sandbox environments clean of none installed extensions.

DavidFeldhoff commented 1 year ago

Hi Freddy, I think my requests relates to this issue: I'd like to uninstall some dev-apps from a SaaS environment. Publish-BCContainerApp e.g. works fine with with the parameters bcAuthContext and environment, but it seems that Unpbulish-BcContainerApp is missing these parameters. Is that doable?

DavidFeldhoff commented 1 year ago

The alternative would be to uninstall apps via the BC Admin API. But unfortunately that isn't working for dev-extensions. @freddydk can you maybe give a short statement if you would pick this up? Otherwise I'd create a support request for the BC Admin API that the uninstall endpoint https://api.businesscentral.dynamics.com/admin/v2.11/applications/BusinessCentral/environments/$environmentName/apps/$appIdToUninstall/uninstall should work for dev-extensions as well, but I could assume that they'd refuse it.

freddydk commented 1 year ago

I will investigate what can be done.

DavidFeldhoff commented 1 year ago

Awesome, thanks!

MikelSeron commented 1 year ago

Hello Freddy! Do you have any news regarding this topic? Thanks!

Spycoclown commented 1 year ago

Hello @freddydk, are there already some news?

freddydk commented 1 year ago

It should be possible to uninstall and unpublish apps through the automation API: https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/administration/resources/dynamics_extension#bound-actions

or through the admin center API https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/administration/administration-center-api_app_management#uninstall-an-app

The automation API should work for both Dev scope and PTEs

I haven't tried and won't have time to investigate right now, if anybody wants to submit a PR with a new function, I will find the time to review.

peterlinnet commented 1 year ago

At a first glance: The automation API does not offer a bound action to unpublish extensions. The admin center API only lists AppSource or firstparty apps, so Dev scope or PTEs are not available here.

So if you use the BC-container-helper's Publish-PerTenantExtensionApps to automate updating PTEs through a deployment pipeline, you'll soon have a history of old versions of the PTE cluttering the customer's list of installed (published) extensions: image

I guess this was the intention of the OP and it's the reason why I'm here looking :)

Tedas1 commented 10 months ago

Hello, did someone solve or found a way to unpublish those cluttered PTE apps?

freddydk commented 10 months ago

@SBalslev - do you know how people can get rid of old PTE versions? (or do you know who knows)

kennetlindberg commented 7 months ago

Hi, also wondering the same thing? Is it possible to unpublish PTE:s through the API? @SBalslev

SilMueller commented 6 months ago

Hello. Has anybody found a solution for this problem?

MBGWS commented 6 months ago

We have the same issue.

Would it make sense to enter an idea in the https://experience.dynamics.com/ideas/-Portal under development and vote for it?

kennetlindberg commented 6 months ago

Here is an old existing idea that I just voted for: https://experience.dynamics.com/ideas/idea/?ideaid=c35221d7-717a-eb11-8fed-0003ff45e089

MBGWS commented 6 months ago

I voted too - could everyone please also share the idea and vote for it?

freddydk commented 2 months ago

Many people have shown interest for this, if my skills in AL code would allow me, I would add this myself, but they don't :-(

I just want to mention that the source code for APIV2 is here: https://github.com/microsoft/ALAppExtensions/tree/main/Apps/W1/APIV2/app

And if you know how to write app code, you can actually add the code yourself by starting here: https://github.com/microsoft/ALAppExtensions/issues/new?assignees=&labels=bcidea&projects=&template=bcidea.yaml&title=%5BBC+Idea%5D%3A+ - specify which idea you want to implement and add the code in a PR.

It is probably a fairly small effort for a skilled app developer - but please create the issue before the PR and discuss best implementation together.

Looking forward to see a solution, which I can implement in BcContainerHelper and AL-Go for GitHub afterwards... :-)

There are several solutions to the problem - one method could be to have a function, which would unpublish all uninstalled apps - this way we can just call that method after installations - and if the installation has a schedule - it won't do anything until next time around.