I'm having a similar issue to this question (https://dba.stackexchange.com/posts/123094/edit)! I have followed the following article: https://azure.microsoft.com/en-gb/documentation/articles/sql-database-manage-logins/ and just cannot get it to fully work.

-- first, connect to the master database

CREATE LOGIN login1 WITH password='password';

-- Establish a new connection to the database

CREATE USER login1user FROM LOGIN login1;


EXEC sp_addrolemember 'db_datareader', 'login1user ';

EXEC sp_addrolemember 'db_datawriter', 'login1user ';

EXEC sp_addrolemember 'db_ddladmin', 'login1user ';

The issue is, I cannot connect to my database with login1user. I have to use the login1 details, which isn't really what I was expecting to happen. I would be happy having the names the same, except for bullet point three in the remarks section of this article (https://msdn.microsoft.com/library/ff929188.aspx), suggests that this isn't best practise.

Any help appreciated!


It looks like you mixed a few different steps from the Azure article. Many of these Azure articles contain lots of great information but the layout is borderline horrible. Topics just blend into each other making it confusing for most readers (DB firewall configuration is another commonly confused doc).

If you want to use contained DBs with contained users, your create user statement should be something like

CREATE USER MyContainedUser01 WITH password='MyL@m3P@$$0rd';

as described in https://azure.microsoft.com/en-gb/documentation/articles/sql-database-manage-logins/#managing-contained-database-users

When you create a user mapped to a login as per your sample script, that's a regular, non-contained user. With that, you need to connect using the login which then maps to the user.

  • also note anything you might see with sp_configure is not needed (or even allowed) with Azure. contained users are always enabled – Simon_Weaver Apr 28 '17 at 21:46

Login to Azure SQL using contained user through Object Explorer of SQL Server Management Studio gives 'Login failure', unless we specify the contained database in the Connection Properties (Options / Connection Properties in login window).

Initial Catalog={contained-db-name};

Login through web app is fine.

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.