Open Closed

Using DbMigrator.exe in CI/CD Deployment Environment - Discussion #5120


User avatar
0
balessi75 created

ABP Commercial 7.2.1 / Blazor Server / EF / Non tiered / Separate Host and Tenant DBs / Lepton Theme

We are currently deploying our ABP solution to an Azure App Service using an Azure DevOps build pipeline that fires off an automated build and release based on commits to an environment specific code branch (dev, qa, staging, etc).

To date, we've been manually running the ABP DbMigrator project from VS against our environment specific Azure SQL DB (dev, qa, staging, etc) whenever new migrations exists. The DbMigrator.exe is great in that it automatically applies schema changes to each tenant separated DB that is defined in the host database.

We would like the DbMigrator process to be automated and synched with the web application deployment using our existing CI/CD process and it's not clear how to set this up.

I'm guessing the DBMigrator.exe would have to be built and deployed somewhere that has access to the host DB running in Azure so that it could be run against it.

Does anyone have any guidance or suggestions on the best approach to accomplish this type of scenario?

Thanks in advance,

Brian


3 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    I'm guessing the DBMigrator.exe would have to be built and deployed somewhere that has access to the host DB running in Azure so that it could be run against it.

    Yes, That's it designed.

  • User Avatar
    1
    ccernat created

    Hi.

    So if you have an Azure DevOps environment.

    1. Publish your artifacts in a pipeline: restore, build, publish web app, publish DbMigrator, publish artifacts

    1. Create a release pipeline and add two stages: one for executing the migration, other for deploying the web apps.

    1. The migration stage depends on where you keen your conn string, I keep them in Azure Key Vault, so I am retrieving them from there:

    3.1 Extract the files

    3.2 Retrieve what you need from KeyVault:

    3.3 Set variable for the current release task to hold the connection string from KeyVaul:

    3.4 Update appsettings.json for the migrator project with a file transform task

    3.5 Run the migrator

    1. Deploy Web Apps - im deploying them to slots

    Another method for publishing your migrations would be to generate the migration scripts and run them in the release pipeline.

    Hope this helps!

    Catalin

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    Thanks!

Made with ❤️ on ABP v9.1.0-preview. Updated on November 11, 2024, 11:11