Create custom user login for Azure SQL Database

Windows Azure user management is a little bit complicated and unfortunately there is no way to add users to existing database using Windows Azure management portal.

In order to add new user to existin database in windows azure you have to do the following:

First you need to create new login on MASTER database using the following command

Important

I it important to verify what database is currently selected, the next step on creating user in azure database, should be done on MASTER database
CREATE LOGIN MyNewDbUser 
WITH PASSWORD = 'P@ssw0rd' 
GO

Then you have to create User on your database using previously created login, using the following command

create user login for azure database

Important

Now you need to switch database to your database where you want to add user, it is not MASTER database anymore
CREATE USER MyNewDbUser 
FOR LOGIN MyNewDbUser 
GO

And the last step is add permissions for the database

Your database again.
EXEC sp_addrolemember N'db_owner', N'MyNewDbUser' 
GO



Comments

Social media

Search

Latest Tweets