I'm attempting to run sqlpackage.exe
from a script executed by AWS CodeDeploy.
The sqlpackage
command runs fine from a local CMD prompt when logged in as the administrator but does not run when called as part of the CodeDeploy pipeline.
The following error occurs:
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)
It would appear that a connection cannot be made to the database.
CodeDeploy runs as a windows service running under aLocal System
account where as my command prompt where this works runs under the Administrator
account. This is the only difference so I think this must be permissions issue.
It would appear that a dacpac needs to be installed by a user with sysadmin
privileges. I attempted (as a test) to set the SQL Server user NT AUTHORITY\SYSTEM
to have a role of DBCreator
.
The deployment then failed with the following error.
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)
I am unsure how to proceed however. I'm guessing that making NT AUTHORITY\SYSTEM
a SysAdmin
is a bad idea!