Azure SQL Database Read Only Access

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up azure sql database read only access by creating a database user and adding it to the fixed reader role. This setup lets people and AI agents read tables without changing any rows. Teams need safe ways to query live data during daily work. Developers check production state to fix bugs. AI agents also run queries to answer support questions. Giving out full admin rights for these tasks creates high risk. A single bad query can drop a table or change customer records. Read-only roles st

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 set up azure sql database read only access by creating a database user and adding it to the fixed reader role. This setup lets people and AI agents read tables without changing any rows.

Teams need safe ways to query live data during daily work. Developers check production state to fix bugs. AI agents also run queries to answer support questions. Giving out full admin rights for these tasks creates high risk. A single bad query can drop a table or change customer records. Read-only roles stop accidental writes before they happen.

How azure sql database read only access works in practice

A database user is the identity of a login inside a database. Admins choose between two main user patterns based on scope. When a person needs to reach many databases on one instance, a SQL user with a login in the master database is common. When someone needs to reach just one or a few databases, a contained database user is an option. A contained user has a password and does not tie to a login in the master database. An admin must first enable contained databases on the server and the database. Across the platform, there are thirteen types of database users.

Once the user exists, an admin assigns a fixed database role. All roles, including the public role, have the basic permission to connect. To grant read rights, the admin adds the user to the fixed data reader role. Members of this reader role can read all data from all user tables and views. You cannot change the permissions assigned to fixed database roles. If an admin wants to block writes for sure, they can also use the deny data writer role. Members of the deny data writer role cannot add, modify, or delete data. By contrast, the data writer role can add, delete, or change data in all user tables. The owner role can do all setup and maintenance tasks and can even drop the database.

Security tradeoffs of static roles and credentials

Fixed database roles handle basic table permissions well, but gaps remain during an active session. First, the fixed data reader role grants read rights across all user tables and views at once. If a table holds sensitive fields like emails, phone numbers, card numbers, or national IDs, a standard reader queries those raw values in full. A static role alone does not rewrite matched fields in results.

Second, static passwords for SQL users or contained users stay valid until an admin rotates them. Teams often share these keys in chat tools or local files. When an engineer leaves or an AI script finishes its job, the shared key still works. Audits also become hard when five people share one read-only login. The database log shows the shared user name rather than the actual person who ran the query.

Auditor Read-Only Access + Database Access Proxy: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Adding runtime controls to database sessions

Modern teams pair database roles with a runtime proxy layer to close these gaps. Instead of handing out static database passwords, the team logs in with their existing work identity. The proxy checks the person or agent before opening the database session. Every query links back to a real user identity in the audit log.

This layer also enforces controls on the data flowing back from the database. Data masking rules inspect query output on the fly and rewrite matched fields in results, such as card numbers, emails, phone numbers, and national IDs. Engineers and AI tools get the schema and rows they need to fix issues, while sensitive fields stay masked in the output.

Add runtime guardrails beside SQL Server

Role grants and network rules are needed setup for SQL Server. Still, an allowed user or agent tool can send a bad delete or read raw customer fields over a valid session. In practice, hoop.dev sits inline in the TDS protocol beside the database as a sidecar for your SQL Server. For every query an agent or human runs in production, hoop.dev decides whether to pass, mask, block, or escalate it for review.

With hoop.dev SQL Server controls, rules refuse banned statements before they run, hold risky queries for human review, and mask matched sensitive values in supported result columns in memory. Furthermore, hoop.dev holds SOC 2 Type II and generates evidence for HIPAA, PCI DSS, SOX, and GDPR audits. See the source on GitHub.

Frequently asked questions

What role grants read-only permissions in SQL databases?

The fixed data reader role lets members read all data from all user tables and views. Admins can also add the deny data writer role so the user cannot add, change, or delete any rows.

Should I use a login in master or a contained database user?

Use a SQL user with a login in master when someone needs access to many databases on one instance. Use a contained database user with a password when someone only needs one or a few databases.

Can I customize the permissions inside a fixed database role?

No, you cannot change the permissions assigned to fixed database roles. If you need custom table rules or field-level masking for emails and card numbers, you must use custom roles or a runtime proxy layer.

The query runs. The emails stay hidden.