Multi-Tenant DB deployments using Azure DevOps
Asked Answered
R

2

8

Our application uses a single code base backed by client-specific databases. What we are trying to achieve is code deployment using usual code push on the IIS website and DB deployments using SQL Dacpac for Schema Only changes on Azure DevOps.

Here the issue is that some of the changes do not go to all the client's databases simultaneously. What we need is a capability to select which would be the target databases for our current release.

Sometimes we will be releasing changes(Schema Only) to all of them, sometimes to few of them.

One way is to create separate release pipelines for all the databases and release them one by one.

Is there a way we can include checkboxes in the release itself, that every release asks me which all db these changes should go?

Another possible solution is finding a way by which I can call 5-10 release pipelines(Each for different DB release) while creating a release from my Main pipeline and have some kind of checkboxes for the releases using which I can pick which ones to do and which ones to skip for this release.

I need suggestions/best industry practices for this scenario.

Rik answered 26/2, 2020 at 8:24 Comment(0)
S
1

Yes, there is. You can configure one release pipeline to have a SQL Server Database Deploy task for each database project. When you use that pipeline create a release, DevOps provides the flexibility by allowing you to enable or disable each task for that specific release. Once you have the release pipeline created, the process is:

  • Select your release pipeline
  • Create release
  • Edit release (not pipeline)
  • Right-click on each SQL Server database deploy task and Enable or Disable as needed
  • Save
  • Deploy
Staffman answered 30/7, 2021 at 18:22 Comment(0)
E
0

You could do it by adding conditionals on each task step that represents deployment to one of yours databases

steps:
- task: PowerShell@2
  condition: eq(variables['deployToDb1'], true)
  inputs:
    targetType: 'inline'
    script: |
      Write-Host "Release to DB 1"
- task: PowerShell@2
  condition: eq(variables['deployToDb2'], true)
  inputs:
    targetType: 'inline'
    script: |
      Write-Host "Release to DB 2"

Variables deployToDb1 and deployToDb2 are defined using UI on Edit Pipeline page and could be overwritten later on the release run enter image description here

Elianaelianora answered 2/8, 2021 at 14:47 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.