Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SqlPackage.exe /AccessToken parameter #2568

Closed
jhursey opened this issue Feb 23, 2021 · 2 comments · Fixed by #2581
Closed

Add SqlPackage.exe /AccessToken parameter #2568

jhursey opened this issue Feb 23, 2021 · 2 comments · Fixed by #2581

Comments

@jhursey
Copy link

jhursey commented Feb 23, 2021

Description

Use the AccessToken parameter for authentication to Azure.

Expected behavior

Setting AccessToken on the deployment parameters gets passed to SqlPackage.exe

@yazeedobaid
Copy link
Collaborator

Is this the form you want:

SqlPackage.deployDb (fun(args:SqlPackage.DeployDbArgs) ->
        { args with
                Destination = "Data Source=https://tcp:your-server-name.database.windows.net; Initial Catalog=database-name;"
                AccessToken = "your-azure-access-token"
                Source = "path-to-sql-project.dacpac"
        })

I was trying with it and it didn't work, I keep receiving the following message:

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: TCP Provider, error: 0 - No such host is known.)

Here the underlying sqlpackage.exe command that FAKE generate:

"C:\Program Files (x86)\Microsoft Visual Studio\2017\SQL\Common7\IDE\Extensions\Microsoft\SQLDB\DAC\150\sqlpackage.exe" /Action:Publish /AccessToken:your-azure-access-token /SourceFile:"path-to-sql-project.dacpac"  /TargetConnectionString:"Data Source=https://tcp:your-server-name.database.windows.net; Initial Catalog=database-name;"  /p:BlockOnPossibleDataLoss=false /p:DropObjectsNotInSource=false /p:CreateNewDatabase=false 

Could you please try running the above command and replace it with your server information? If it is working with you I guess then it is a problem with my connection/setup. If that is the case I can send a PR for it.
Thanks

@jhursey
Copy link
Author

jhursey commented Apr 1, 2021

The proposed form is exactly what I am looking for.

Your attached PowerShell command works if the access token is in quotes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants