Credentials using Invoke-Sqlcmd against sql azure
It could be the password contains a few special characters that Azure/Invoke-sqlcmd does not handle (such as dollar, single or double quote, parentheses). I tried using the Azure interface and surrounding the password with single-quotes (we had a dollar-sign in the password), but that did not work. So, we simply removed the special character and now it is OK. see: Powershell Invoke-Sqlcmd Login Failedand https://mohitgoyal.co/2017/08/09/vsts-azure-sql-database-deployment-task-keeps-failing-with-error-login-failed-for-user/
When connecting to SQL Azure the login name must be of the form user@server
. So if you created an user 'foo' and a server 'bar', the login must be foo@bar
. See Managing Databases and Logins in Azure SQL Database:
Because some tools implement tabular data stream (TDS) differently, you may need to append the Azure SQL Database server name to the login in the connection string using the
<login>@<server>
notation. In these cases, separate the login and Azure SQL Database server name with the@
symbol. For example, if your login was namedlogin1
and the fully qualified name of your Azure SQL Database server isservername.database.windows.net
, the username parameter of your connection string should be:login1@servername
.
CREATE LOGIN also explains this:
In some methods of connecting to SQL Database, such as sqlcmd, you must append the SQL Database server name to the login name in the connection string by using the
<login>@<server>
notation. For example, if your login islogin1
and the fully qualified name of the SQL Database server isservername.database.windows.net
, the username parameter of the connection string should belogin1@servername
.