HodorNV / ALOps

ALOps
59 stars 24 forks source link

Update AppSource App with AdminCenter API #596

Closed CarloAxians closed 8 months ago

CarloAxians commented 1 year ago

Describe the bug We want to update our AppSource app with the AdminCenter API.

the used yaml If we specify the app-id we want to update, we receive the error ##[error]*** 'App ID' specified, filtering updates

- task: Hodor.hodor-alops.ALOpsAdminCenterAPI.ALOpsAdminCenterAPI@1
  displayName: 'Update App'
  inputs:
    azure_tenant_id: '$(CustomerTenantId)'
    azure_app_client_id: '$(appautomation.clientid)'
    azure_app_client_secret: '$(appautomation.clientsecret)'
    interaction: 'app_update'
    environment: '$(TstEnvironment)'
    app_id: '$(app_id)'

the output

2022-12-20T12:41:58.9214909Z *** Imported required PS-Functions
2022-12-20T12:42:00.1641370Z *** Parse Task Parameters
2022-12-20T12:42:00.2103274Z *** Creating API Connector with endpoint [https://api.businesscentral.dynamics.com/]
2022-12-20T12:42:00.2626438Z *** API Authentication: Using Azure OAuth Authentication [<redacted>]
2022-12-20T12:42:00.2657957Z *** Get OAuth token for tenant [<redacted>]
2022-12-20T12:42:00.3098304Z *** Communication: Service-2-Service (Client Secret)
2022-12-20T12:42:00.3205943Z ##[command]Invoke-RestMethod -Method Post -Uri "https://login.microsoftonline.com/<redacted>/oauth2/token"
2022-12-20T12:42:00.9810220Z *** Interaction: app_update
2022-12-20T12:42:00.9880861Z ##[command]Invoke-RestMethod -Method Get -Uri 'https://api.businesscentral.dynamics.com/admin/v2.6/applications/BusinessCentral/environments/CarloTst/apps/availableUpdates'
2022-12-20T12:42:06.2880842Z Available App Updates:
2022-12-20T12:42:06.5200946Z ##[error]*** 'App ID' specified, filtering updates
2022-12-20T12:42:06.5846494Z ##[section]Finishing: Install

the used yaml If we remove the app-id, we receive the error ##[error]Exception in BCConnector.PostAPIData: De externe server heeft een fout geretourneerd: (404) Niet gevonden.

- task: Hodor.hodor-alops.ALOpsAdminCenterAPI.ALOpsAdminCenterAPI@1
  displayName: 'Update App'
  inputs:
    azure_tenant_id: '$(CustomerTenantId)'
    azure_app_client_id: '$(appautomation.clientid)'
    azure_app_client_secret: '$(appautomation.clientsecret)'
    interaction: 'app_update'
    environment: '$(TstEnvironment)'

the output

2022-12-20T12:52:20.3210517Z *** Imported required PS-Functions
2022-12-20T12:52:21.5762220Z *** Parse Task Parameters
2022-12-20T12:52:21.6135988Z *** Creating API Connector with endpoint [https://api.businesscentral.dynamics.com/]
2022-12-20T12:52:21.6619689Z *** API Authentication: Using Azure OAuth Authentication [<Redacted>]
2022-12-20T12:52:21.6647465Z *** Get OAuth token for tenant [<Redacted>]
2022-12-20T12:52:21.7077252Z *** Communication: Service-2-Service (Client Secret)
2022-12-20T12:52:21.7124255Z ##[command]Invoke-RestMethod -Method Post -Uri "https://login.microsoftonline.com/<Redacted>/oauth2/token"
2022-12-20T12:52:22.3222798Z *** Interaction: app_update
2022-12-20T12:52:22.3294780Z ##[command]Invoke-RestMethod -Method Get -Uri 'https://api.businesscentral.dynamics.com/admin/v2.6/applications/BusinessCentral/environments/CarloTst/apps/availableUpdates'
2022-12-20T12:52:23.7291437Z Available App Updates:
2022-12-20T12:52:23.7382620Z 
2022-12-20T12:52:23.7383697Z 
2022-12-20T12:52:23.7384796Z appId        : <Redacted>
2022-12-20T12:52:23.7389463Z name         : <Redacted>
2022-12-20T12:52:23.7391028Z publisher    : Axians Business Solutions
2022-12-20T12:52:23.7392145Z version      : 22.11.20221206.10956
2022-12-20T12:52:23.7393310Z requirements : {}
2022-12-20T12:52:23.7393724Z 
2022-12-20T12:52:23.7397851Z 
2022-12-20T12:52:23.7398368Z 
2022-12-20T12:52:23.7398813Z 
2022-12-20T12:52:23.7434473Z *** Update App [<Redacted>] to version [22.11.20221206.10956]
2022-12-20T12:52:23.7538271Z ##[command]Invoke-RestMethod -Method Post -Uri 'https://api.businesscentral.dynamics.com/admin/v2.13/applications/BusinessCentral/environments/CarloTst/apps//update'
2022-12-20T12:52:23.8262514Z ##[error]Exception in BCConnector.PostAPIData: De externe server heeft een fout geretourneerd: (404) Niet gevonden.
2022-12-20T12:52:24.0311009Z ##[error]Exception in BCConnector.PostAPIData: De externe server heeft een fout geretourneerd: (404) Niet gevonden.
2022-12-20T12:52:24.1039226Z ##[section]Finishing: Update

Expected behavior There are two API call's, the availableUpdates API should be without the app-id and the update API with the app-id. ../apps//update should be ../apps/app-id/update

waldo1001 commented 1 year ago

It looks like you are using the wrong approach. But just to verify: your want to publish your new version of the app to an online sandbox to test your AppSource app in that sandbox?

If so, the only way to do that is to use dev-port deployment.

You can do that with the "ALOps Extension API" step, and set up a "dev_endpoint" (like: "https://api.businesscentral.dynamics.com/v2.0/YourEnvironmentName/")

CarloAxians commented 1 year ago

No, I want to update an app that is in the AppSource with the AdminCenter update API. https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/administration/administration-center-api_app_management#update-an-app

So we have released a new version of our app in the AppSource and from DevOps we want to initiate the update process, in stead of manually perform the update from the Admin Center: image

waldo1001 commented 1 year ago

Ah - clear - will look into it!

waldo1001 commented 1 year ago

Just meant as an update: we made significant progress on this. We decided to not do it as BCCH, but build smart features (auto-discovery) to make the deployment process easy. More soon!

fvet commented 1 year ago

More soon!

@waldo1001 I guess we've arrived at 'soon' in the meanwhile :)

Any news to share?

waldo1001 commented 1 year ago

Well - in our next release, there will be a new step, which is going to be a very automatic approach to the upload.

Based on the apps that you download (artifacts), and the connection to your marketplace, it will figure out all offerings, search apps and library apps (dependencies) in the artifact folders, and update it online.

It's going to be a fully automated process, all you need to have is an offering online, and that app (and its dependencies) in some kind of folder on the build server.

StevenHit commented 11 months ago

Hi, I am facing the same issue when using ALOpsAdminCenterAPI to update an app. Is this still an issue in ALOps or am I doing something wrong? image

waldo1001 commented 11 months ago

Are you sue this is part of this issue?

This issue is about the AppSource upload - a step that has been released quite some time ago.

You are talking admincenter - which is not the same.

StevenHit commented 11 months ago

Hi Erik, If I read below, Carlo wants to use the ALOpsAdminCenterAPI command to update an already installed app on a BC cloud environment. That's exactly what I want to do. And I also get the same error. image

waldo1001 commented 11 months ago

My bad, sorry .. I was confused with another issue :-/.

ALOps should work - we are using it every single day to update apps.

Can you please send Yaml and Log?

StevenHit commented 11 months ago

No problem. I attached both now. I replaced tenant & client ID.

Yaml.txt 2_MPI_BCNL_LIVE.log

StevenHit commented 11 months ago

Hi, Were you able to find a cause/solution for the issue? We would like to start using app updates via ALOPs/DevOps. Thx

waldo1001 commented 11 months ago

You won't believe it, but we were just setting up test-scenarios for this .. . And we believe we have a repro .. (as said, we're using this ourselve every.single.day - so we were surprised.. .

I'll keep you posted..

waldo1001 commented 11 months ago

We performed a bugfix in the latest release - can you confirm it works now?

StevenHit commented 11 months ago

I just tried. Unfortunately, it's telling me that there are no apps available for update. But BC admin shows me there is a new version to install... Can you check please? Log.txt image

StevenHit commented 11 months ago

Hi - Any news on this one please? We want to start using ALOps for App Updates soon. Thx.

waldo1001 commented 11 months ago

Hm. We're gong to change the output so we'll print all available updates so we can figure out why this is not working ..

StevenHit commented 11 months ago

Good morning, do you have news on this one please?

StevenHit commented 10 months ago

Hello, any news please?

waldo1001 commented 10 months ago

We have been trying and retrying .. but finally our eye caught a very stupid mistake .. . In stead of appId, we used Id .. so it was never using the right Id.

So sorry .. sometimes the simplest issues are the hardest to find :'(.

hotfix coming up

StevenHit commented 10 months ago

2_HMD_BCNL_UPG.log

Hi, maybe I was a bit to early, but I just retried and it still doesn't work. Can you check please?