Azure DevOps - 恢复数据库的管道发布任务

Azure DevOps - Pipeline Release Task to Restore Database

Azure DevOps 的发布管道(由 Microsoft 或第 3 方创建)中是否有任务能够连接到我的数据库并执行我拥有的存储过程来恢复我的数据库?

目前,我必须通过远程桌面进入我的 SQL Server 2019 数据库所在的虚拟机并执行我的恢复脚本。我想做的是有一个任务可以访问我的 VM 中的数据库并为我恢复它,但我不确定我将如何去做,或者即使该功能存在。

目前在 Azure 管道的 SQL 服务器数据库中没有可用的 pre-defined tasks 来执行 sql 脚本。

作为解决方法,您可以尝试deploy self-hosted agent on your VM, and then use this agent in release pipeline, so the release will run on your VM. And you could run your sql script using the Command Line task or PowerShell task. See: Custom Azure DevOps pipeline task to execute a SQL script了解更多详情。

顺便说一句,我们找到了这个第 3 方扩展:SQLplus Executer - Release Edition,它可以使用 SQLplus 执行 sql 文件。你可以检查一下。