Azure / SQL Server / Cannot open user default database (Login failed)

You want to create a new login on Azure Logical SQL Server using your Azure Admin account.

To do that you must be connected to the master database on SQL Azure with the administrative login.


After that, you need to create new DB user for that login (db_owner in this example). To be able to do that you must be connected as an admin to the database where you want to create that user.


Now, if you try to connect to that db using SSMS you need to specify default DB for that user.


Since you cannot set the default database property for the login, default DB will always be [master] database.

If you do not change DB before connection, and user do not have rights to access master DB, you can face following error

The server principal “azure_db_user” is not able to access the database “master” under the current security context.
Cannot open user default database. Login failed.
Login failed for user ‘azure_db_user’. (.Net SqlClient Data Provider)


You can also use connection string from azure portal specifying Initial Catalog (DB Name)



Similar Posts:

6 Responses to “ “Azure / SQL Server / Cannot open user default database (Login failed)”

  1. Luis Forero says:

    cool thanks

  2. Subramani S says:

    Really useful, i got the solution after 2 days from this blog.
    Great work..

  3. Hue says:

    Dude. This is the best answer on the web. Thank you!

Leave a Reply

Your email address will not be published. Required fields are marked *