microsoft / AL-Go

The plug-and-play DevOps solution for Business Central app development on GitHub
MIT License
270 stars 113 forks source link

Deployment step fails when retried #557

Open gntpet opened 1 year ago

gntpet commented 1 year ago

Hey @freddydk,

In development scenarios it's quite common that we do breaking changes, and our deployment pipelines failed. I already requested such a feature https://github.com/microsoft/AL-Go/issues/227

In the meantime, what we do in these scenarios is to upload extension manually using "Extension Management" page with param "Force", and the re-run just deployment step. This trick used to work, but not anymore.

What happens now, is we get "Internal Server Error Object reference not set to an instance of an object."

I have a feeling it fails, because it cannot install extension with the same version, that was installed already.

1st attempt looks like this: It fails because of the breaking change

Run microsoft/AL-Go-Actions/Deploy@v3.1
Run try { D:\a\_actions\microsoft\AL-Go-Actions\v3.1\Deploy/Deploy.ps1 -actor $ENV:_actor -token $ENV:_token -parentTelemetryScopeJson $ENV:_parentTelemetryScopeJson -projects $ENV:_projects -environmentName $ENV:_environmentName -artifacts $ENV:_artifacts -type $ENV:_type } catch { Write-Host "::Error::Unexpected error when running action ($($_.Exception.Message.Replace("`r",'').Replace("`n",' ')))"; exit 1 }
Downloading BcContainerHelper latest version from CDN
BcContainerHelper version 5.0.3
BC.HelperFunctions emits usage statistics telemetry to Microsoft
project '***'
Apps to deploy
D:\a\srs-bc\srs-bc\.artifacts\***-main-Apps-1.0.489.0
Attempting authentication to https://api.businesscentral.dynamics.com/user_impersonation offline_access using refresh token...
Authenticated using refresh token as user Gintautas (gintautas@verysecretname.onmicrosoft.com)
https://businesscentral.dynamics.com/65d1aab7-6256-47e9-836c-23cceed270cf/ITQA/deployment/url
Publishing apps using development endpoint
Publishing SRS_azure-blob-storage-setup_1.0.489.0.app to https://api.businesscentral.dynamics.com/v2.0/ITQA/dev/apps?SchemaUpdateMode=synchronize
App SRS_azure-blob-storage-setup_1.0.489.0.app successfully published
Publishing SRS_bank-acount-for-sales-docs_1.0.489.0.app to https://api.businesscentral.dynamics.com/v2.0/ITQA/dev/apps?SchemaUpdateMode=synchronize
App SRS_bank-acount-for-sales-docs_1.0.489.0.app successfully published
Publishing SRS_data-replication_1.0.489.0.app to https://api.businesscentral.dynamics.com/v2.0/ITQA/dev/apps?SchemaUpdateMode=synchronize
App SRS_data-replication_1.0.489.0.app successfully published
Publishing SRS_dynamic-layout_1.0.489.0.app to https://api.businesscentral.dynamics.com/v2.0/ITQA/dev/apps?SchemaUpdateMode=synchronize
App SRS_dynamic-layout_1.0.489.0.app successfully published
Publishing SRS_email-queue_1.0.489.0.app to https://api.businesscentral.dynamics.com/v2.0/ITQA/dev/apps?SchemaUpdateMode=synchronize
App SRS_email-queue_1.0.489.0.app successfully published
Publishing SRS_fattura-invoice-export_1.0.489.0.app to https://api.businesscentral.dynamics.com/v2.0/ITQA/dev/apps?SchemaUpdateMode=synchronize
App SRS_fattura-invoice-export_1.0.489.0.app successfully published
Publishing SRS_SRS.core_1.0.489.0.app to https://api.businesscentral.dynamics.com/v2.0/ITQA/dev/apps?SchemaUpdateMode=synchronize
Publish-BcContainerApp Telemetry Correlation Id: 97481e6b-8f7a-4f[93](https://github.com/sede-res/srs-bc/actions/runs/5122655231/jobs/9212607129#step:8:94)-bc2c-65cab41675e0
Error: Deploying to ITQA failed.  Status Code 422 : Unprocessable Entity Impossibile aggiornare l'estensione NAV 'SRS.core by SRS 1.0.489.0' a causa dell'errore seguente: 'Table 50046 Reverse APS Entry :: Impossibile trovare la tabella "Reverse APS Entry". La rimozione delle tabelle non è consentita se non sono temporanee o sono state spostate dalla migrazione in un'altra app.'. 
Removing BcContainerHelper
Error: Process completed with exit code 1.

2nd attempt looks like this:

Run microsoft/AL-Go-Actions/Deploy@v3.1
Run try { D:\a\_actions\microsoft\AL-Go-Actions\v3.1\Deploy/Deploy.ps1 -actor $ENV:_actor -token $ENV:_token -parentTelemetryScopeJson $ENV:_parentTelemetryScopeJson -projects $ENV:_projects -environmentName $ENV:_environmentName -artifacts $ENV:_artifacts -type $ENV:_type } catch { Write-Host "::Error::Unexpected error when running action ($($_.Exception.Message.Replace("`r",'').Replace("`n",' ')))"; exit 1 }
Downloading BcContainerHelper latest version from CDN
BcContainerHelper version 5.0.3
BC.HelperFunctions emits usage statistics telemetry to Microsoft
project '***'
Apps to deploy
D:\a\srs-bc\srs-bc\.artifacts\***-main-Apps-1.0.489.0
Attempting authentication to https://api.businesscentral.dynamics.com/user_impersonation offline_access using refresh token...
Authenticated using refresh token as user Gintautas (gintautas@verysecretname.onmicrosoft.com)
https://businesscentral.dynamics.com/65d1aab7-6256-47e9-836c-23cceed270cf/ITQA/deployment/url
Publishing apps using development endpoint
Publishing SRS_azure-blob-storage-setup_1.0.489.0.app to https://api.businesscentral.dynamics.com/v2.0/ITQA/dev/apps?SchemaUpdateMode=synchronize
Publish-BcContainerApp Telemetry Correlation Id: 4d6f3c69-e9d6-490f-b8d1-5a1222aca5ac
Error: Deploying to ITQA failed.  Status Code InternalServerError : Internal Server Error Object reference not set to an instance of an object.
Removing BcContainerHelper
Error: Process completed with exit code 1.

What we do now, is upload extension with force, and then re-run entire workflow. But, it takes double amount of time, instead of simple retry.

Is there something you can help with?

Best Regards, Gintautas

freddydk commented 1 year ago

Will have a look at implementing support for the force mode

gntpet commented 1 year ago

I would prefer that you would fix "retry job" flow first. It used to work correctly before. It's really annoying, since the jobs takes ages. So, if you want to deploy your changes with breaking changes, you basically wait for almost an hour.