Azure SQL Permissions

Published
Length
3 min read

Luis Felipe Dias

All posts

You manage azure sql permissions by mapping server logins or contained users to database roles. These roles control who can read, write, or change tables in your database. A database user is the identity of a login when it connects to a database. Teams use two main user setups based on how many databases a person needs. If an engineer needs many databases on one instance, a SQL user with a login works well. That login lives in the master database. If a user needs just one database, a contained

Your coding agents run with your access.

Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.

You manage azure sql permissions by mapping server logins or contained users to database roles. These roles control who can read, write, or change tables in your database.

A database user is the identity of a login when it connects to a database. Teams use two main user setups based on how many databases a person needs. If an engineer needs many databases on one instance, a SQL user with a login works well. That login lives in the master database.

If a user needs just one database, a contained database user is another option. A contained user has a password and does not tie to a login in master. An admin must first turn on contained databases on the server and the database. Across the engine, there are 13 types of database users.

How azure sql permissions work for engineers and AI agents

Once a user identity exists, admins assign it to fixed database roles. All roles, including the public role, have basic permission to connect. Still, the rules assigned to fixed database roles cannot be changed.

For read access, teams add users to the fixed data reader role. Members of this role can read all data from all user tables and views. For write access, teams use the fixed data writer role. Members can add, delete, or change data in all user tables.

Admins can also block actions with deny roles. A deny data reader role stops a user from reading any user tables or views. It also blocks metadata about those tables. A deny data writer role stops a user from adding, changing, or deleting data.

The database owner role holds the highest power inside a database. Members can run all setup and maintenance tasks and can even drop the database. Both human engineers and AI agents use these same user identities and roles when they run queries.

Azure RBAC + AI Agent Permissions: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Security tradeoffs of static roles and live sessions

Built-in database roles handle broad table access well, but they have clear limits. Because you cannot change the rules of fixed roles, they grant wide access by default. A data reader role lets a person or AI agent read every single user table.

If a table holds customer emails, phone numbers, card numbers, or national IDs, a reader role exposes them. Anyone in that role gets the full rows back when they run a query. The same risk applies to write access.

A data writer role lets an engineer change or delete rows in any user table. One bad query can wipe out production rows across the whole database. Static passwords for contained users or master logins also create ongoing risk.

When teams share database keys in local files, you lose track of who ran which query. Two engineers using one login look identical in the database logs. Also, once a session starts, native roles do not pause a risky command for human review.

To reduce these risks, teams pair native roles with query-level controls. Adding an approval step before a write query runs stops bad deletes. Also, data masking rewrites matched fields like emails or card numbers in query results.

Check SQL Server batches and results on the wire

SQL Server logins and roles decide who connects. They do not check what each TDS batch does or mask sensitive values in returned rows. With hoop.dev, you run an open-source proxy, a sidecar for your SQL Server, inline in the TDS wire protocol. On every batch an AI agent or engineer runs against production, hoop.dev decides to pass, mask, block, or hold it for human review.

Before a batch hits the server, hoop.dev guardrails refuse disallowed actions with a native TDS error or hold risky statements for approval. On the way back, hoop.dev data masking rewrites sensitive values in supported result columns in memory, and every decision is logged. Explore the MIT-licensed project on GitHub.

Frequently asked questions

What is the difference between a login user and a contained user?

A login user ties to a central login in the master database for multi-database access. A contained user logs into one database with a password and has no login in master.

Can I customize the rules inside a fixed database role?

No, the permissions assigned to fixed database roles cannot be changed. If you need custom table rules, you must create your own user-defined roles instead.

How do I stop a user from reading data without removing their account?

You can add the user to the fixed deny data reader role. Members of this role cannot read any data or metadata from user tables and views.

The query runs. The emails stay hidden.