Azure SQL Server Configuration
3 min
Purpose
In Azure SQL Server, similar to MSSQL, but with Azure-specific roles like MS_ServerStateReader. The goal is to create a login and user with minimal read privileges.
Grant Permissions
-- Create a server login
CREATE LOGIN [ username ] WITH PASSWORD = ’password ’;
-- Assign the ServerStateReader role to allow viewing server state
5 ALTER SERVER ROLE ## MS_ServerStateReader ## ADD MEMBER [ username ];
-- Optionally , assign the DefinitionReader role for object definitions
ALTER SERVER ROLE ## MS_DefinitionReader ## ADD MEMBER [ username ];
-- Create a database user associated with the login
CREATE USER [ username ] FROM LOGIN [ username ];Testing Permissions
Connect as [username] to the Azure SQL Server and execute:
SELECT * FROM sys . dm_os_windows_info ;If the query returns data, [username] can view the server state, indicating that permissions are set up properly.