Azure SQL Database Audit Logs
You use azure sql database audit logs to track every login and query. These logs record who ran a command and when it happened. Engineering teams rely on these records to review activity across their cloud data stores. When an engineer or an automated script runs a query, the system writes an event. This event captures the user identity, the target table, and the time of the action. Security teams later check these files to find bad queries or strange login patterns. How azure sql database au
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 use azure sql database audit logs to track every login and query. These logs record who ran a command and when it happened.
Engineering teams rely on these records to review activity across their cloud data stores. When an engineer or an automated script runs a query, the system writes an event. This event captures the user identity, the target table, and the time of the action. Security teams later check these files to find bad queries or strange login patterns.
How azure sql database audit logs work in practice
To understand what appears in your logs, you must first understand database identities. A database user is the identity of a login when it connects to a database. People who need access to many databases on an instance often use a login in master. For access to one or a few databases, a contained database user is an option. This user has a password and is not tied to a login in master. An admin must first turn on contained databases on the server and the database. Across the platform, there are thirteen types of database users.
When any of these users run queries, azure sql database audit logs capture the activity. This applies to both human engineers and AI agents that query your tables. AI agents often use fixed credentials to connect and pull context for their tasks. If three engineers and two bots share one login, the logs show one user name. You can see the SQL text they ran, but you cannot tell who ran it. Tying every action to a real person or specific agent requires unique identities.
Security tradeoffs of fixed roles and static logins
Database admins often use fixed database roles to control what users can do. Every role, including the public role, has basic permission to connect. You cannot change the permissions assigned to fixed database roles. For read access, admins add users to the data reader role. Members of this role can read all data from all user tables and views. If you want to block reads, the deny data reader role stops all table reads. It also blocks views and metadata about them.
For write access, the data writer role lets users add, delete, or change table data. The deny data writer role stops a user from adding, changing, or deleting data. At the top level, the owner role can do all setup and maintenance tasks. Members of the owner role can even drop the database in SQL Server. While azure sql database audit logs record what these roles do, logs only look backward. A log tells you that a user read sensitive rows after the query finishes.
Kubernetes Audit Logs + Database Audit Policies: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
This creates a gap during an active session. A user with the data reader role can pull all column in every user table by default. That includes emails, phone numbers, card numbers, and national IDs. Audit logs will record the select query, but they do not hide the raw values. Also, static passwords stored in app files can leak. If an attacker steals a reader key, they can read all user tables right away.
Adding query controls and data masking before the database
Relying only on native roles and past logs leaves live sessions too open. Teams can close this gap by placing a proxy layer in front of the database. Instead of giving out static passwords, engineers log in with their work identity. This maps every query in your logs to a real person, not a shared login.
A proxy layer also lets you inspect commands before the database runs them. You can require a peer to approve write queries before they touch user tables. For read queries, dynamic data masking can rewrite matched fields in the results. It replaces emails, phone numbers, card numbers, and national IDs with masked text in real time. Your team gets the data they need, and your audit logs stay clean and clear.
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 is the difference between a master login and a contained user?
A login in master works well when someone needs access to many databases on an instance. A contained user stays inside one database and does not need a master login.
Can I customize the permissions of fixed database roles to limit audit scope?
No, you cannot change the permissions assigned to fixed database roles. For example, the data reader role always grants read access to all user tables and views.
Do audit logs stop users from reading sensitive columns?
No, audit logs only record that a query ran after the fact. To hide fields like card numbers or emails in results, you must apply data masking.
Related guides
In this post