我正在尝试sqlpackage.exe
从 AWS CodeDeploy 执行的脚本运行。
以管理员身份登录时,该sqlpackage
命令在本地 CMD 提示符下运行良好,但在作为 CodeDeploy 管道的一部分调用时不运行。
出现以下错误:
An unexpected failure occurred: DacInstance with the specified instance_id does not exist..
Unhandled Exception: System.Data.SqlClient.SqlException: DacInstance with the specified instance_id does not exist.
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
似乎无法与数据库建立连接。
CodeDeploy 作为在Local System
帐户下运行的 Windows 服务运行,而我的命令提示符在该Administrator
帐户下运行。这是唯一的区别,所以我认为这一定是权限问题。
似乎需要由具有sysadmin
特权的用户安装 dacpac。我尝试(作为测试)将 SQL Server 用户设置NT AUTHORITY\SYSTEM
为具有DBCreator
.
然后部署失败并出现以下错误。
The database settings cannot be modified. You must be a SysAdmin to apply these settings.
The database settings cannot be modified. You must be a SysAdmin to apply these settings.
An error occurred while the batch was being executed.
Updating database (Failed)
但是,我不确定如何进行。我猜做NT AUTHORITY\SYSTEM
一个SysAdmin
是个坏主意!