VSTS:部署 Azure SQL DACPAC 发布管理引发错误

VSTS: Deploy Azure SQL DACPAC Release Management throwing an error

我正在尝试为我的 Azure SQL 数据库设置 VSTS 版本管理。我正在使用 "Deploy Azure SQL DACPAC" 任务。 dacpac 文件的路径设置为

$(System.DefaultWorkingDirectory)\**\*.dacpac

虽然数据库正确更新,但最后出现错误导致任务失败。

"System.Management.Automation.ParentContainsErrorRecordException: *** Could not deploy package"

看起来所有更新都已应用到数据库,但任务仍然抛出错误。在下方登录

2016-07-07T07:50:44.6118522Z Publishing to database 'mydb' on server 'myserver.database.windows.net'.
2016-07-07T07:50:45.7587428Z Initializing deployment (Start)
2016-07-07T07:50:52.5825349Z Initializing deployment (Complete)
2016-07-07T07:50:52.5835341Z Analyzing deployment plan (Start)
2016-07-07T07:50:52.7085342Z Analyzing deployment plan (Complete)
2016-07-07T07:50:52.7085342Z Updating database (Start)
2016-07-07T07:50:53.7000358Z Altering [dbo].[usp_Products_List]...
2016-07-07T07:50:53.7170379Z Creating [dbo].[usp_Products_GetById]...
2016-07-07T07:50:53.8745919Z An error occurred while the batch was being executed.
2016-07-07T07:50:53.8855912Z Updating database (Failed)
2016-07-07T07:50:53.9105905Z ##[debug]System.Management.Automation.RemoteException: *** Could not deploy package.
2016-07-07T07:50:53.9225921Z ##[debug][Azure RDFE Call] Deleting firewall rule 260745ad-327c-45ae-bcb8-5c6bb0e43797 on azure database server: myserver
2016-07-07T07:50:55.9753040Z ##[debug][Azure RDFE Call] Firewall rule 260745ad-327c-45ae-bcb8-5c6bb0e43797 deleted on azure database server: myserver
2016-07-07T07:50:55.9934761Z ##[error]System.Management.Automation.ParentContainsErrorRecordException: *** Could not deploy package.

存储过程代码

CREATE PROCEDURE [dbo].[usp_Products_GetById]
    @pId int
AS
    SET NOCOUNT ON;

SELECT [id]
      ,[description]
      ,[created_dt]
      ,[last_mod_dt]
      ,[active]
  FROM [dbo].[Products]
  WHERE [id] = @pId
GO

这通常是因为您的 SQL 项目的 "Target platform" 与您正在部署的 SQL 服务器版本不匹配。请检查您的 SQL 项目的 "Target platform" 是否与 Azure SQL 数据库版本匹配:

我尝试手动设置防火墙规则并仅使用服务器名称而不是 FQDN。然后我再次尝试 FQDN,它成功了。所以不确定为什么会失败。

在我的特定情况下,发生此错误是因为在我的数据库项目中,在 table 的一个初始化脚本中,我试图为非数字列设置标识规范。

因此,如果其他解决方案不起作用,请检查所有脚本 运行 是否没有错误(使用 SQL Management Studio 或 Visual Studio)。

太糟糕了,VSTS 中的错误没有捕获 SQL 错误...