Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uninstall app in scope:dev using ALops Admincenter API #634

Open
MortenRa opened this issue May 11, 2023 · 8 comments
Open

Uninstall app in scope:dev using ALops Admincenter API #634

MortenRa opened this issue May 11, 2023 · 8 comments

Comments

@MortenRa
Copy link

Describe the bug
I´m trying to uninstall an app which is deployed as scope:dev in a partner Saas Sandbox using ALops Admincenter API but get this error and not sure if this is setup or it is because the scope is dev or not supported.

BCConnector.PostAPIData: {"code":"EntityValidationFailed","message":"Entity validation failed: App to uninstall is not installed.\r\n-App ID: '9cf9feca-8d2d-49f3-a03d-6ae05f910b2c'\r\n-Environment: 'App-UAT'"}

the used yaml
please provide the yaml that you used. It helps you put the yaml like this:

steps:
- task: Hodor.hodor-alops.ALOpsAdminCenterAPI.ALOpsAdminCenterAPI@1
  displayName: 'ALOps AdminCenter API'
  inputs:
    azure_tenant_id: '$(Staging_tenant_id)'
    azure_app_client_id: '$(StagingClientID)'
    azure_app_client_secret: '$(StagingClientSecret)'
    interaction: 'app_uninstall'
    environment: '$(App-UAT)'
    target_environment: '$(App-UAT)'
    app_id: '9cf9feca-8d2d-49f3-a03d-6ae05f910b2c'
    accept_isv_eula: true
  continueOnError: true

the output
Also the complete output is necessary for us to see what is going on. Also use backtics:

2023-05-11T07:21:25.9734661Z ##[section]Starting: ALOps AdminCenter API
2023-05-11T07:21:25.9936343Z ==============================================================================
2023-05-11T07:21:25.9936810Z Task         : ALOps AdminCenter API
2023-05-11T07:21:25.9937694Z Description  : Interact with BC SaaS AdminCenter API
2023-05-11T07:21:25.9938001Z Version      : 1.455.3607
2023-05-11T07:21:25.9938253Z Author       : Hodor
2023-05-11T07:21:25.9940192Z Help         : Interact with BC SaaS AdminCenter API.
2023-05-11T07:21:25.9940626Z ==============================================================================
2023-05-11T07:21:26.0982952Z ##[warning]Environment variable 'VSTS_PUBLIC_VARIABLES' exceeds the maximum supported length. Environment variable length: 52525 , Maximum supported length: 32766
2023-05-11T07:21:27.6899828Z *** Validate configuration
2023-05-11T07:21:27.8071851Z *** Task Inputs:
2023-05-11T07:21:27.8146580Z 
2023-05-11T07:21:27.8338733Z name                                  value                                   
2023-05-11T07:21:27.8347244Z ----                                  -----                                   
2023-05-11T07:21:27.8353975Z azure_tenant_id                       xxx    
2023-05-11T07:21:27.8360452Z azure_app_client_id                   ***    
2023-05-11T07:21:27.8365194Z azure_app_client_secret               ***
2023-05-11T07:21:27.8371384Z azure_app_client_certificate                                                  
2023-05-11T07:21:27.8378020Z azure_app_client_certificate_password                                         
2023-05-11T07:21:27.8382204Z username                                                                      
2023-05-11T07:21:27.8388585Z password                                                                      
2023-05-11T07:21:27.8394347Z checksecondsdelay                     30                                      
2023-05-11T07:21:27.8400586Z maxtries                              20                                      
2023-05-11T07:21:27.8404845Z interaction                           app_uninstall                           
2023-05-11T07:21:27.8410930Z wait_for_operation                    True                                    
2023-05-11T07:21:27.8416264Z environment                           App-UAT                                 
2023-05-11T07:21:27.8420380Z target_environment                    App-UAT                                 
2023-05-11T07:21:27.8426164Z use_update_window                     False                                   
2023-05-11T07:21:27.8432017Z app_id                                9cf9feca-8d2d-49f3-a03d-6ae05f910b2c    
2023-05-11T07:21:27.8435429Z accept_isv_eula                       True                                    
2023-05-11T07:21:27.8441894Z force_dependencies                    False                                   
2023-05-11T07:21:27.8445981Z confirm_delete_data                   False                                   
2023-05-11T07:21:27.8446699Z 
2023-05-11T07:21:27.8476370Z 
2023-05-11T07:21:27.8492569Z 
2023-05-11T07:21:27.8797021Z *** For documentation, please visit   : https://www.alops.be/documentation
2023-05-11T07:21:27.8826331Z 

2023-05-11T07:21:28.2331310Z 
2023-05-11T07:21:28.2498523Z *** Imported required PS-Functions
2023-05-11T07:21:28.2810969Z *** Parse Task Parameters
2023-05-11T07:21:28.3972328Z *** Creating API Connector with endpoint [https://api.businesscentral.dynamics.com/]
2023-05-11T07:21:28.4522500Z *** API Authentication: Using Azure OAuth Authentication [***]
2023-05-11T07:21:28.4561626Z *** Get OAuth token for tenant [xxx]
2023-05-11T07:21:28.4842973Z *** Communication: Service-2-Service (Client Secret)
2023-05-11T07:21:28.4893311Z ##[command]Invoke-RestMethod -Method Post -Uri "https://login.microsoftonline.com/xxx/oauth2/token"
2023-05-11T07:21:28.6040609Z *** Interaction: app_uninstall
2023-05-11T07:21:28.6137829Z ##[command]Invoke-RestMethod -Method Post -Uri 'https://api.businesscentral.dynamics.com/***/v2.13/applications/BusinessCentral/environments/App-UAT/apps/9cf9feca-8d2d-49f3-a03d-6ae05f910b2c/uninstall'
2023-05-11T07:21:30.6581450Z ##[error]Exception in BCConnector.PostAPIData: {"code":"EntityValidationFailed","message":"Entity validation failed: App to uninstall is not installed.\r\n-App ID: '9cf9feca-8d2d-49f3-a03d-6ae05f910b2c'\r\n-Environment: 'App-UAT'"}
2023-05-11T07:21:30.8124150Z ##[error]Exception in BCConnector.PostAPIData: {"code":"EntityValidationFailed","message":"Entity validation failed: App to uninstall is not installed.\r\n-App ID: '9cf9feca-8d2d-49f3-a03d-6ae05f910b2c'\r\n-Environment: 'App-UAT'"}
2023-05-11T07:21:30.8561014Z ##[section]Finishing: ALOps AdminCenter API

Expected behavior
the app to be uninstalled

@waldo1001
Copy link
Collaborator

Are you sure it's possible to uninstall an app through the API that hasn't been installed through the API (dev-scope is installed through the dev endpoint...)?

We're merely using the API, so whatever error that comes back from the API endpoint, we throw in the pipeline..

🤔

@MortenRa
Copy link
Author

Nope not sure, but I can get a list of Installed Apps from the api (also those in dev scope) so was hoping it was possible :-)

@Arthurvdv
Copy link

Not sure if this is helpful, but I can share some insights on this with the ALOpsExtensionAPI.

When a extensions is installed through the API (dev-scope), then using the ALOpsExtensionAPI it will run into a failure.
2023-05-16T13:31:21.3440147Z ##[error]App publish failed. Check the 'Extension Deployment Status' page in the Business Central client.

When going into the environment and opening the Extension Deployment Status page, the error there shows
An extension with app Id '<redacted>' is currently installed on this environment as a DEV extension. Please uninstall this extension before attempting to install an extension with the same app Id as a per-tenant extension.

@waldo1001
Copy link
Collaborator

Not sure what we need to do here.. I have a feeling you're mixing different things here .. dev-extensions uninstalling with devops flows .. that's going to be difficult (keep in mind you're not able to uninstall with VSCode either). Also to investigate .. 🤔

@MortenRa
Copy link
Author

Hi, let me try to explain my situation maybe another approach from my site is needed.

We use Partner Sandbox as UAT, and we have around 40 apps where we have a library apps which all 40 apps has a dependency app on.

We publish through Release Pipelines with the ALOps Extension API in Devscope. when we publish an update of the Library app with Dev Schema Update Mode: Synchronize or Forcesync it will :

-Uninstall all 40 apps (due to dependency)
-Publish the library app
-Install the library app
-Install all the dependency apps

But the Release Pipeline never gets an "OK" response so it will continue until timeout (event through it is actually is finished) but the status of the release Pipeline is then failed and next step is not run (I have allowed it to continue on Error but would like it to actually show correct status)

I did manually test that if I uninstall library app and run the release pipeline for the update if goes through fine. That was why I tried to use the ALops Admincenter API to uninstall the Library app first before updating the app. Hence my Issue.

Any Ideas for another Approach

@waldo1001
Copy link
Collaborator

Can you send us a complete log about this (from the release pipeline)?

@waldo1001
Copy link
Collaborator

@MortenRa ?

@MortenRa
Copy link
Author

MortenRa commented Jul 6, 2023

Here is the log.

Uninstall app.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants