Azure SQL Database "Login failed for user" in application, but works fine in SSMS

We found that with contained databases / contained users you must specify:

GRANT CONNECT TO [YOUR_USER]

Otherwise CONNECT seems to be revoked by default. Once we made the above change, we could access the database.


When switching our API to connect to an Azure database via a new contained user, we had to change our connection string to include:

Persist Security Info=True;

While I don't understand why this change was required, I wanted to post here in case it helps someone else out in the future.

We originally came to try this from this question.


My problem was different, but related: I was trying to connect to a Azure SQL database by using SQL Server Management Studio (SSMS) with a contained user. I was getting a "Login failed for user" message in SSMS.

Solution: in the SSMS connection options for the query window I had set the "Connect to Database" to the name of the database to which I was trying to connect.

Explanation: In hindsight the reason was obvious: contained users are allowed only to connect to the database(s) in which they were created.