Base solution for your next web application
Open Closed

CI-CD Migrator #11103


User avatar
0
henryand created

we use ANZ 10.1 Angular/Core combined

Our application is multi-tenant with separate databases and a host db. I am in the process of setting up a CICD pipeline in Azure DevOps to build and publish our site when a merge request has been completed. This gets the hosted app up to date but migrations still need to be run on the database.

with the app publish automated, the database update also needs to be automated. what is the recommended process for running EF migrations in a CICD flow?

Thanks, Rocco


6 Answer(s)
  • User Avatar
    0
    staffing created

    Hi Rocco,

    You need to do this in the Azure Pipeline. First you can create a build and then create a release. You can create the script or dacpac file. In the release you can create task to migrate the database.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @henryand

    You can publish the Migrator app as well and run it with the Main DB's connection string on your Azure environment.

  • User Avatar
    0
    elecosoftseservice created

    I'm also wanting to do exactly this.

    Should I publish the Migrator app to the same Azure app server as the Middleware/API web app?

    Then create and configure a Release task to execute the Migrator?

    Many Thanks

  • User Avatar
    0
    marble68 created

    FWIW - that's exactly what I do. I use GitHub actions, and I as part of my powershell build script, I build and run the migrator.

  • User Avatar
    0
    elecosoftseservice created

    For the benefit of any others trying to solve this, I finally managed to get this working as part of the DevOps Release pipeline, but encountered many problems along the way.

    Most notable is that if I tried to execute the Migrator exe as part of the Release agent tasks, it failed to access the Azure SQL Database - this is because it is running in the context of the Agent server, whose IP address is taken from a pool, and that pool is cycled weekly, so no chance of Whitelisting it in the Azure SQL Server firewall.

    I got around this by creating a new MVC Controller in the Web.Host project, and added an Action that launches the Migrator exe. Then I created a PowerShell task in the Release pipeline that make a simple Http Get call to the new Action.

  • User Avatar
    0
    marble68 created

    This is a good idea.