简体   繁体   English

使用 Azure DevOps 的多租户数据库部署

[英]Multi-Tenant DB deployments using Azure DevOps

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.我们试图实现的是使用 IIS 网站上的常规代码推送进行代码部署,并使用 SQL Dacpac 进行数据库部署,仅对 Azure DevOps 进行更改

Here the issue is that some of the changes do not go to all the client's databases simultaneously.这里的问题是某些更改不会同时对所有客户端的数据库进行 go。 What we need is a capability to select which would be the target databases for our current release.我们需要的是 select 的能力,这将是我们当前版本的目标数据库。

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?有没有办法我们可以在版本本身中包含复选框,每个版本都会询问我这些更改应该 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.另一种可能的解决方案是找到一种方法,在从我的主管道创建一个版本时,我可以调用 5-10 个发布管道(每个用于不同的数据库版本),并为发布提供某种复选框,我可以使用这些复选框来选择要执行的操作以及此版本要跳过哪些。

I need suggestions/best industry practices for this scenario.我需要针对这种情况的建议/最佳行业实践。

Yes, there is.就在这里。 You can configure one release pipeline to have a SQL Server Database Deploy task for each database project.您可以配置一个发布管道,为每个数据库项目设置一个 SQL Server 数据库部署任务。 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.当您使用该管道创建一个版本时,DevOps 通过允许您启用或禁用该特定版本的每个任务来提供灵活性。 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右键单击每个 SQL Server 数据库部署任务并根据需要启用或禁用
  • Save节省
  • Deploy部署

You could do it by adding conditionals on each task step that represents deployment to one of yours databases您可以通过在代表部署到您的一个数据库的每个任务步骤上添加conditionals来做到这一点

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变量deployToDb1deployToDb2是在Edit Pipeline页面上使用 UI 定义的,稍后可以在发布运行时被覆盖在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM