You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Feb 9, 2024. It is now read-only.
I have an existing Linux-based dockerfile, which publishes some dacpacs to a local database and this works fine.
However, I have now changed it because I want to import a bacpac including data. I have changed the sqlpackage command only to specify /a:Import and it points to a bacpac instead of a dacpac but it doesn't work, I see this error logged:
Importing to database 'SPC_Test' on server 'localhost'.
Creating deployment plan
Initializing deployment
*** Error importing database:Could not import package.
Unable to connect to target server 'localhost'. Please verify the connection information such as the server name, login credentials, and firewall rules for the target server.
Cannot open database "SPC_Test" requested by the login. The login failed.
Login failed for user 'sa'.
My understanding from msdn is that if the database does not exist, it will be created but the error seems to suggest this is not the case.
If this is the case, the error message should be more specific "Cannot import into new database, create the database first". If this is not the case, then I am stuck as to what I have done wrong. The relevant excerp from the dockerfile is below:
ENV ACCEPT_EULA="Y"ENV SA_PASSWORD="P@ssW0rd!"# Install Unzip# Install SQLPackage for Linux and make it executable# Get bacpac/dacpac from buildCOPY Database/bin/Release/*.bacpac /tmp/
# See https://stackoverflow.com/a/51589787/488695 about waiting for sql to startRUN ( /opt/mssql/bin/sqlservr & ) | grep -q "Service Broker manager has started" \
&& /opt/sqlpackage/sqlpackage /a:Import /tsn:localhost /tdn:SPC_Test /tu:sa /tp:$SA_PASSWORD /sf:/tmp/FuncTest.bacpac \
&& rm /tmp/*.bacpac && pkill sqlservr
The text was updated successfully, but these errors were encountered:
@lukos I see that you closed this - but I noticed that you're using sa to run sqlpackage here so the database would be created by the import action.
My guess is that the engine hasn't finished starting up (despite the stackoverflow method).
For what it's worth, my preferred method of checking that the engine is ready to run queries is using sqlcmd to run something like "select * from sys.databases" in a limited loop until it responds. I've been doing this in the past prior to publishing dacpacs and just tested it with importing a bacpac without an issue. https://github.com/dzsquared/sql-development-tools/blob/main/.devcontainer/mssql/postCreateCommand.sh
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
I have an existing Linux-based dockerfile, which publishes some dacpacs to a local database and this works fine.
However, I have now changed it because I want to import a bacpac including data. I have changed the sqlpackage command only to specify /a:Import and it points to a bacpac instead of a dacpac but it doesn't work, I see this error logged:
My understanding from msdn is that if the database does not exist, it will be created but the error seems to suggest this is not the case.
If this is the case, the error message should be more specific "Cannot import into new database, create the database first". If this is not the case, then I am stuck as to what I have done wrong. The relevant excerp from the dockerfile is below:
The text was updated successfully, but these errors were encountered: