Thursday, December 17, 2020

Login failed for user when connecting to Azure SQL

Problem:  When using dotnet ef database update to create database schema for Azure SQL DB. Errored out with below (Login failed for user). But no problem logging in from Managemnet Studio using same credential. Username and password are in connection string as test.

 try, DbConnectionOptions userOptions, DbConnectionInternal& connection)
   at Microsoft.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
   at Microsoft.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)Error Number:18456,State:1,Class:14
Login failed for user 'xxxx'.

Issue: Seems for some reason the command not able to handle special character in password (with special characters in connection string. 

Resolution: Updated the admin password without special characters and it worked fine (You can do so easily with powershell or on Azure admin UI). There were suggestions to escape them with backlash or quote etc,none worked for me so far. Idea?

No comments:

Post a Comment