I get randomly from time to time error Login failed for user '***' when the application tries to connect with Azure SQL Database.
In most cases application has no problem with logging in to that user, unfortunately from time to time I get such an error. DB hasn't problems (at least I don't see any of them) isn't overloaded no alerts, only that problem that happens from time to time
Login failed for user '***'
The error occurs when the username or password or there's something missing in the connection string. You can check the Azure SQL log-in logs in the Audit Logs section of your Azure SQL server and you can explicitly view #sys.event_log logs table to check the connectivity failures of your Azure SQL.
I created one console app and reproduced the same Login failed for user error where my db name in the connection string is wrong, Similar error might occur if you add an incorrect password or if a password change is not updated in your connection string Refer to below:-
You can enable Audit Logs for your Azure SQL DB like below to get more insights on the connection failure:-
Audit Logs are sent to Log analytics like below:-
Database Authentication logs:-
You can also auto-resolve the connection issue by visiting Diagnose and solve problems section of your Azure SQL DB where you can select your issue and Azure will run diagnostics queries/recommendation on your Azure SQL DB like below:-
For Connectivity - Connection Timeouts issues, Query is recommended like below:-
You can also query the connection failed logs directly in the SSMS like below:-
Select * From sys.event_log
Reference:-
sys.event_log (Azure SQL Database) - SQL Server | Microsoft Learn
Azure SQL Auditing for Azure SQL Database and Azure Synapse Analytics - Azure SQL Database | Microsoft Learn
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.