Friday, January 24, 2020

Azure devops Invoke-Sqlcmd login failed

In one of the projects using Azure devops deployment pipelines the deployment worked on Staging, but failed on production server. Logs indicated that a command using Invoke-Sqlcmd failed to authenticate the user. Error returned was of the form



Login failed for user '<User Id>'

The problem here is related to special characters in the password. So if Invoke-Sqlcmd command has special characters in a password and the password is enclosed with double quotes, it does not treat the password as literal string and instead tries to interpret it in different way. Thus the authentication fails.

Unfortunately since VSTS does not allow password to be passed using single quotes, the only option we have is to change the user's password.

More information about this error can be found at:

https://mohitgoyal.co/2017/08/09/vsts-azure-sql-database-deployment-task-keeps-failing-with-error-login-failed-for-user/

and also at

https://stackoverflow.com/questions/22335651/powershell-invoke-sqlcmd-login-failed

Many thanks to them.

No comments:

c# httpclient The remote certificate is invalid according to the validation procedure: RemoteCertificateNameMismatch

 If we get this error while trying to get http reponse using HttpClient object, it could mean that certificate validation fails for the remo...