使用 CI/CD 管道部署数据库项目时如何设置 SQL 用户密码

How to set SQL user password when deploying database project using CI/CD pipeline

我在 Visual Studio 中有数据库项目 (.sqlproj),我在其中创建这样的用户:

CREATE USER [MyUser] WITHOUT LOGIN; --I dont want to store password in source control
GO
ALTER ROLE [db_datareader] ADD MEMBER [MyUser]
GO
ALTER ROLE [db_datawriter] ADD MEMBER [MyUser]
GO
ALTER ROLE [db_executor] ADD MEMBER [MyUser]

我在 VSTS Build 中构建 dacpack 并将其部署到 VSTS Release 中的 Azure:

如何设置持续部署以创建带密码的用户?

This Azure Marketplace 中的插件可能有用。

您还可以使用 PowerShell 创建登录并包括条件执行。

解释了更多选择here

希望对您有所帮助。