{{tag>db microsoft azure cloud database sql}} ====== Connect to Azure database ====== First download the [[https://learn.microsoft.com/en-us/azure-data-studio/download-azure-data-studio?tabs=linux-install%2Cwin-user-install%2Cubuntu-install%2Cwindows-uninstall%2Credhat-uninstall#download-azure-data-studio|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 {{ :wiki:screenshots:azure_data_studio1.png?200 |}} **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; Add read permissions to user EXEC sp_addrolemember 'db_datareader', 'rouser'; You need to repeat this step for each DB. Check users SELECT * FROM sys.sysusers; 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. {{ :wiki:screenshots:azure_data_studio2.png?200 |}} ====== 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 ====== * [[wiki:updateing_azure_database_firewall_via_api|Updateing Azure database firewall via Azure API]] ====== References ====== * https://azure.microsoft.com/en-us/blog/adding-users-to-your-sql-azure-database/ * https://learn.microsoft.com/en-us/azure/azure-sql/database/logins-create-manage?view=azuresql