Azure 如何删除VSTS DacpacTask中的列?

Azure 如何删除VSTS DacpacTask中的列?,azure,azure-devops,azure-pipelines-release-pipeline,Azure,Azure Devops,Azure Pipelines Release Pipeline,我在VSTS中有一个构建步骤,它生成一个.dacpac文件,我将该文件传递给发布定义,然后发布定义使用executeAzure SQL:DacpacTask更新数据库。当我尝试删除列时,这是DacpacTask的输出: 2016-10-26T18:12:01.3300540Z ##[section]Starting: Execute Azure SQL : DacpacTask 2016-10-26T18:12:01.3674946Z ==============================

我在VSTS中有一个构建步骤,它生成一个
.dacpac
文件,我将该文件传递给发布定义,然后发布定义使用executeAzure SQL:DacpacTask更新数据库。当我尝试删除列时,这是DacpacTask的输出:

2016-10-26T18:12:01.3300540Z ##[section]Starting: Execute Azure SQL : DacpacTask
2016-10-26T18:12:01.3674946Z ==============================================================================
2016-10-26T18:12:01.3674946Z Task         : Azure SQL Database Deployment
2016-10-26T18:12:01.3674946Z Description  : Deploy Azure SQL DB using DACPAC or run scripts using SQLCMD
2016-10-26T18:12:01.3674946Z Version      : 1.1.2
2016-10-26T18:12:01.3674946Z Author       : Microsoft Corporation
2016-10-26T18:12:01.3674946Z Help         : [More Information](https://aka.ms/sqlazuredeployreadme)
2016-10-26T18:12:01.3674946Z ==============================================================================
2016-10-26T18:12:04.8304591Z packageFile= C:\a\r1\a\MyProject\Database\Database.dacpac
2016-10-26T18:12:07.4389560Z Publishing to database 'MyDB' on server 'mydatabase.database.windows.net'.
2016-10-26T18:12:08.3318189Z Initializing deployment (Start)
2016-10-26T18:12:25.4560124Z *** The column [dbo].[Foo].[Bar] is being dropped, data loss could occur.
2016-10-26T18:12:26.2098293Z Initializing deployment (Complete)
2016-10-26T18:12:26.2098293Z Analyzing deployment plan (Start)
2016-10-26T18:12:26.2098293Z Analyzing deployment plan (Complete)
2016-10-26T18:12:26.2098293Z Updating database (Start)
2016-10-26T18:12:29.5605253Z An error occurred while the batch was being executed.
2016-10-26T18:12:29.5675257Z Updating database (Failed)
2016-10-26T18:12:30.4919483Z 
2016-10-26T18:12:30.6439495Z ##[error]

SerializedRemoteException      : 
SerializedRemoteInvocationInfo : 
ErrorRecord                    : *** Could not deploy package.
StackTrace                     :    at System.Management.Automation.Interpreter.ThrowInstruction.Run(InterpretedFrame 
                                 frame)
                                    at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(Int
                                 erpretedFrame frame)
WasThrownFromThrowStatement    : True
Message                        : *** Could not deploy package.
Data                           : {System.Management.Automation.Interpreter.InterpretedFrameInfo}
InnerException                 : 
TargetSite                     : Void CheckActionPreference(System.Management.Automation.Language.FunctionContext, 
                                 System.Exception)
HelpLink                       : 
Source                         : System.Management.Automation
HResult                        : -2146233087

2016-10-26T18:12:30.6629481Z ##[section]Finishing: Execute Azure SQL : DacpacTask
该构建中还包含了一些其他的数据库更改,但是当我恢复删除该列的提交时,发布成功了

我还验证了,即使
栏中只有
NULL
s,也会出现相同的问题

(显然,我可以使用SSMS手动删除该列,但使用CI/CD系统的目的是实现所有操作的自动化,因此我不必这样做。)


如何使用VSTS DacpacTask删除列?

您需要在Execute Azure SQL:DacpacTask生成步骤的附加SqlPackage.exe参数中将BlockOnPossibleDataLoss参数指定为false。

您需要在Execute Azure SQL:DacpackTask生成步骤的附加SqlPackage.exe参数中将BlockOnPossibleDataLoss参数指定为false。