Home > Net >  Not able to connect to Azure SQL database from Microsoft SQL Server Management Tool
Not able to connect to Azure SQL database from Microsoft SQL Server Management Tool

Time:09-26

I am able to connect to Azure SQL Server from liquibase using jtds drivers and run the query.

When I am trying to connect from SQL Server Management Studio, using the same credentials:

  • Server Type: Database Engine
  • Server Name: myserver.database.windows.net,1433
  • Authentication: SQL Server authentication
  • Login: username (username and password are provided appropriately)
  • Password: password

I get the error as shown below.

Note: I have changed the server name as it is confidential.

Cannot connect to myserver.database.windows.net,1433.

Login failed for user 'username'. (.Net SqlClient Data Provider)

Server Name: myserver.database.windows.net,1433
Error Number: 18456
Severity: 14
State: 1
Line Number: 65536

Program Location:

at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, DbConnectionPool pool, String accessToken, Boolean applyTransientFaultHandling, SqlAuthenticationProviderManager sqlAuthProviderManager)
at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
at System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup, DbConnectionOptions userOptions)
at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection) at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource1 retry, DbConnectionOptions userOptions)
at System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource1 retry, DbConnectionOptions userOptions) at System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource1 retry)
at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
at System.Data.SqlClient.SqlConnection.Open()
at Microsoft.SqlServer.Management.SqlStudio.Explorer.ObjectExplorerService.ValidateConnection(UIConnectionInfo ci, IServerType server)
at Microsoft.SqlServer.Management.UI.ConnectionDlg.Connector.ConnectionThreadUser()

CodePudding user response:

The server name should be something like this servername.database.windows.net

You can get the server name from portal from Overview or from Azure SQL database connection string.

enter image description here

In SSMS, give the copied server name from the portal as shown in screenshot.

Do not give port number in the server name while connecting from SSMS.

enter image description here

Refer this Microsoft document for more information.

CodePudding user response:

I have found Error 18456 with State 1 only during Microsoft Azure outages. To make sure visit @AzureSupport on Twitter or visit Azure Status. Sometimes Azure Support and Azure Status do not show any issues because issues may not be affecting a good number of customers, but you can still find out what is happening by going to Help Support, choose Service Health, then examine "Health History" and "Resource Health" as shown on this article.

Another possible cause of this error is the status of your Azure Subscription. Maybe your subscription requires your attention.

  • Related