microsoft / mssql-scripter

Repository for the new SQL cross-platform command line tools
Other
738 stars 147 forks source link

Failed to login to AzureDB #97

Open MikeSpark opened 7 years ago

MikeSpark commented 7 years ago

Using correct credential but cannot connect to AzureDB, with error Login failed.

C:\Users\UserName>mssql-scripter --version 1.0.0a12

C:\Users\UserName>mssql-scripter -S ae-az-dw-prod.database.windows.net -d bidw_prod -U etluser Password: Scripting request: 484b9114-e793-4760-8743-2a9b8509e96a encountered error: Failed to connect to server ae-az-dw-prod.database.windows.net. Error details: Microsoft.SqlServer.Management.Common.ConnectionFailureException: Failed to connect to server ae-az-dw-prod.database.windows.net. ---> System.Data.SqlClient.SqlException: Login failed for user 'etluser'. at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerIn fo, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, Boolean applyTransientFaultHandling) at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderIn fo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions) at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions option s, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions) at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConne ction) at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal old Connection) at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection) at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource1 retry, DbConnectionOptions userOpti ons, DbConnectionInternal& connection) at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource1 retry, DbConnectionOptions u serOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection) at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, Tas kCompletionSource1 retry, DbConnectionOptions userOptions) at System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletio nSource1 retry, DbConnectionOptions userOptions) at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry) at System.Data.SqlClient.SqlConnection.Open() at Microsoft.SqlServer.Management.Common.ConnectionManager.InternalConnect() at Microsoft.SqlServer.Management.Common.ConnectionManager.Connect() --- End of inner exception stack trace --- at Microsoft.SqlServer.Management.Common.ConnectionManager.Connect() at Microsoft.SqlServer.Management.Common.ConnectionManager.PoolConnect() at Microsoft.SqlServer.Management.Common.ConnectionManager.GetServerInformation() at Microsoft.SqlServer.Management.Smo.Server.IsAzureDbScopedConnection(ServerConnection sc) at Microsoft.SqlServer.Management.Smo.Server.GetExecutionManager() at Microsoft.SqlServer.Management.Smo.Server.get_ExecutionManager() at Microsoft.SqlServer.Management.Smo.SqlSmoObject.get_ServerVersion() at Microsoft.SqlServer.Management.Smo.Server.get_Version() at Microsoft.SqlServer.Management.SqlScriptPublish.SqlScriptPublishModel.GetAdvancedScriptingOptions() at Microsoft.SqlTools.ServiceLayer.Scripting.ScriptingScriptOperation.BuildPublishModel() in D:\repos\sqltoolsservice\src\Microsoft.SqlTools.Servic eLayer\Scripting\ScriptingScriptOperation.cs:line 162 at Microsoft.SqlTools.ServiceLayer.Scripting.ScriptingScriptOperation.Execute() in D:\repos\sqltoolsservice\src\Microsoft.SqlTools.ServiceLayer\Scr ipting\ScriptingScriptOperation.cs:line 70

MrMeemus commented 7 years ago

@MikeSpark from what I can see in the stack track, it just looks like invalid credentials.

Are you sure the credentials passed in are correct? Perhaps there's a fire wall that you configure?

Any other info or details would help :)

Thanks, Ron

MikeSpark commented 7 years ago

@MrMeemus Thanks for the responds. I'm sure the credential is correct. Double checked with sqlcmd on same host.

C:\Users\Admin.Mikec>sqlcmd -S ae-az-dw-prod.database.windows.net -d bidw_prod -U etluser -I Password: Sqlcmd: Error: Microsoft SQL Server Native Client 11.0 : Login failed for user 'etluser'.. C:\Users\Admin.Mikec>sqlcmd -S ae-az-dw-prod.database.windows.net -d bidw_prod -U etluser -I Password: 1> select count(*) from sys.schemas 2> go ----------- 70 (1 rows affected) 1> QUIT Therefore it proven same credential works in SQLCMD. In fact I have been using SSMS and SQLCMD as I already configured the firewall correct to this machine. ![image](https://user-images.githubusercontent.com/8683422/27536217-234fdc5c-5a66-11e7-8156-8ea800beb9f2.png) As problem isolation, could you or anyone else on this forum test the same version mssql-scripter with an Azure SQL (Not the DW one)? Thanks.
MrMeemus commented 7 years ago

@MikeSpark , I wasn't able to repro this issue targeting one of my test servers in Azure.

Could you try downloading our latest release (Just pushed today) and let me know if you still have a issue?

MikeSpark commented 7 years ago

@MrMeemus, Is the 1.0.0a13 latest version? I downloaded and tested and it's the same result.

C:\Users\Admin.Mikec>pip install mssql-scripter Collecting mssql-scripter Downloading mssql-scripter-1.0.0a13.tar.gz Requirement already satisfied: future>=0.16.0 in c:\users\admin.mikec\appdata\local\programs\python\python36-32\lib\site-packages (from mssql-scripter ) Requirement already satisfied: wheel>=0.29.0 in c:\users\admin.mikec\appdata\local\programs\python\python36-32\lib\site-packages (from mssql-scripter)

Collecting mssqltoolsservice_Windows_7_86==1.0.0a13 (from mssql-scripter) Downloading mssqltoolsservice_Windows_7_86-1.0.0a13-py2.py3-none-any.whl (26.0MB) 100% |████████████████████████████████| 26.0MB 18kB/s Building wheels for collected packages: mssql-scripter Running setup.py bdist_wheel for mssql-scripter ... done Stored in directory: C:\Users\Admin.Mikec\AppData\Local\pip\Cache\wheels\a2\aa\ad\a44cc28e36ef7e2ed713c67270b4b5f5c9014c788465ca8bff Successfully built mssql-scripter Installing collected packages: mssqltoolsservice-Windows-7-86, mssql-scripter Found existing installation: mssqltoolsservice-Windows-7-86 1.0.0a12 Uninstalling mssqltoolsservice-Windows-7-86-1.0.0a12: Successfully uninstalled mssqltoolsservice-Windows-7-86-1.0.0a12 Successfully installed mssql-scripter-1.0.0a13 mssqltoolsservice-Windows-7-86-1.0.0a13

C:\Users\Admin.Mikec>mssql-scripter --version 1.0.0a13

C:\Users\Admin.Mikec>mssql-scripter -S ae-az-dw-prod.database.windows.net -d bidw_prod -U etluser -P {I input password here} Scripting request: 51539c39-3e44-4f5f-a087-e25daa387c94 encountered error: Failed to connect to server ae-az-dw-prod.database.windows.net. Error details: Microsoft.SqlServer.Management.Common.ConnectionFailureException: Failed to connect to server ae-az-dw-prod.database.windows.net. ---> System.Data.SqlClient.SqlException: Login failed for user 'etluser'. at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerIn fo, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, Boolean applyTransientFaultHandling) at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderIn fo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions) at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions option s, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions) at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConne ction) at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal old Connection) at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection) at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource1 retry, DbConnectionOptions userOpti ons, DbConnectionInternal& connection) at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource1 retry, DbConnectionOptions u serOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection) at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, Tas kCompletionSource1 retry, DbConnectionOptions userOptions) at System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletio nSource1 retry, DbConnectionOptions userOptions) at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry) at System.Data.SqlClient.SqlConnection.Open() at Microsoft.SqlServer.Management.Common.ConnectionManager.InternalConnect() at Microsoft.SqlServer.Management.Common.ConnectionManager.Connect() --- End of inner exception stack trace --- at Microsoft.SqlServer.Management.Common.ConnectionManager.Connect() at Microsoft.SqlServer.Management.Common.ConnectionManager.PoolConnect() at Microsoft.SqlServer.Management.Common.ConnectionManager.GetServerInformation() at Microsoft.SqlServer.Management.Smo.Server.IsAzureDbScopedConnection(ServerConnection sc) at Microsoft.SqlServer.Management.Smo.Server.GetExecutionManager() at Microsoft.SqlServer.Management.Smo.Server.get_ExecutionManager() at Microsoft.SqlServer.Management.Smo.SqlSmoObject.get_ServerVersion() at Microsoft.SqlServer.Management.Smo.Server.get_Version() at Microsoft.SqlServer.Management.SqlScriptPublish.SqlScriptPublishModel.GetAdvancedScriptingOptions() at Microsoft.SqlTools.ServiceLayer.Scripting.ScriptingScriptOperation.BuildPublishModel() in D:\GitHub\sqltoolsservice\src\Microsoft.SqlTools.Servi ceLayer\Scripting\ScriptingScriptOperation.cs:line 162 at Microsoft.SqlTools.ServiceLayer.Scripting.ScriptingScriptOperation.Execute() in D:\GitHub\sqltoolsservice\src\Microsoft.SqlTools.ServiceLayer\Sc ripting\ScriptingScriptOperation.cs:line 70

MikeSpark commented 7 years ago

Do you think it is related to my virutal server name? There are several "-" within ae-az-dw-prod.database.windows.net

MrMeemus commented 7 years ago

@MikeSpark I wasn't able to repro this issue even when targeting our azure servers with multiple dashes in the name. The next step I would recommend is generating and sharing the logs with us by adding a additional flag to the command "--enable-toolsservice-logging" from there you will find log dumps in your user directory.

Additional ask, would it be possible to add me as a user on the database in question so I can debug testing a connection against it?

wojtekswi commented 3 years ago

Hi, Were you able to fix the issue? Im getting the same problems now with connecting to the azure sql. im using 1.0.0a23 version.