User Tools

Site Tools


wiki:connect_azure_database

Connect to Azure database

First download the Azure Data Studio as you need access to master database which you can't see via the Azure portal.

Read-only user

This is an example for login, you can also use user accounts and couple of other ways. Refer to docs below.

1. Connect to the database via admin user

2. Select master database then New Query

3. Create new login:

CREATE LOGIN my_readonlylogin WITH PASSWORD = 'SuperSecret52&&'

Check with:

SELECT * FROM sys.sql_logins;

4. Switch to DB (e.g. somedb_DEV) to which you need access and create user

CREATE USER rouser FROM LOGIN my_readonlylogin;

You need to repeat this step for each DB.

Check users

SELECT * FROM sys.sysusers;

Add read permissions to user (needed only once)

EXEC sp_addrolemember 'db_datareader', 'rouser';

Now use my_readonlylogin as user to login not the user created :shrug: Under database field select the database as well otherwise the default is to connect to master DB.

Tested on

  • Azure Data Studio

Version: 1.48.0 Commit: 4970733324ef8254b7c22a5dc55af7f8a1dea93f Date: 2024-02-26T20:54:08.538Z VS Code: 1.82.0 Electron: 25.9.8 Chromium: 114.0.5735.289 Node.js: 18.15.0 V8: 11.4.183.29-electron.0 OS: Linux x64 6.5.0-27-generic

See also

References

wiki/connect_azure_database.txt · Last modified: 2024/04/25 13:14 by antisa

Except where otherwise noted, content on this wiki is licensed under the following license: CC0 1.0 Universal
CC0 1.0 Universal Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki