Azure SQL Query Logs
Teams use azure sql query logs to record every statement that runs against a database. These logs show who ran a query, when it ran, and what data changed. Good logs help you spot slow queries and pass security audits. Yet native logs only tell you what happened after a query finishes. They cannot block bad commands or hide private fields before results return. How azure sql query logs work in practice Every entry in your azure sql query logs ties back to a database user. A database user is
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.
Teams use azure sql query logs to record every statement that runs against a database. These logs show who ran a query, when it ran, and what data changed.
Good logs help you spot slow queries and pass security audits. Yet native logs only tell you what happened after a query finishes. They cannot block bad commands or hide private fields before results return.
How azure sql query logs work in practice
Every entry in your azure sql query logs ties back to a database user. A database user is the identity of a login when it connects to a database. Microsoft SQL engines support 13 types of database users for different access needs.
For people who need access to many databases on an instance, a login is common. This SQL user ties to a login in the master database. For access to one or a few databases, a contained database user is an option. A contained user is a SQL user with a password, not tied to master. An admin must first enable contained databases on the server and the database.
When an engineer or AI agent runs a query, the engine logs that user identity. Still, teams often share one login across many people, apps, or scripts. When ten engineers share one login, the query log shows the same user name. You can see the SQL text in the log, but not the real person.
Security tradeoffs of static roles and native logs
Database admins often pair query logging with fixed database roles to limit damage. All roles, including the public role, have basic connect rights. The permissions assigned to fixed database roles cannot be changed by admins.
SQL Query Filtering + Azure RBAC: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Members of the datareader role can read all data from all user tables and views. Members of the datawriter role can add, delete, or change data in all user tables. To block access, admins assign deny roles to specific accounts. A denydatareader role cannot read any data from user tables, views, or metadata. A denydatawriter role cannot add, modify, or delete data in any user table. At the top level, the owner role can run all maintenance tasks and drop databases.
These fixed roles and native query logs still leave big security gaps during live sessions. A datareader user can pull every row from a table with customer secrets by default. Native logs will record the read query, but they do not hide the output. Masking at the query layer rewrites matched fields like emails, phone numbers, and card numbers. It also rewrites national IDs in query results before the user or agent reads them. Also, a datawriter user can delete rows by mistake if no approval step exists.
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 do azure sql query logs capture during a session?
They record the SQL statement, the timestamp, and the database user account that ran it. If your team shares a single login, the log cannot show which individual ran the query.
Can I change the permissions inside a fixed database role?
No, the permissions assigned to fixed database roles cannot be changed in SQL Server. If a role grants too much access, you must use custom roles or query controls.
Do read-only roles protect sensitive columns from appearing in query results?
No, members of the standard read role can read all data from all user tables. To protect emails, phone numbers, or card numbers, you need data masking in the path.
Related guides
In this post