Openhands Azure SQL

Published
Length
3 min read

Luis Felipe Dias

All posts

An openhands azure sql setup lets an AI agent run queries on cloud databases. Teams set up a database user and a fixed role to control what the agent does. Autonomous coding tools help teams build apps and fix bugs fast. Yet giving an AI agent direct database keys brings real risks. A bad query can change live rows or pull sensitive user records. Teams need clear boundaries before they let an agent touch a live database. How openhands azure sql works in practice The agent runs inside a local

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.

An openhands azure sql setup lets an AI agent run queries on cloud databases. Teams set up a database user and a fixed role to control what the agent does.

Autonomous coding tools help teams build apps and fix bugs fast. Yet giving an AI agent direct database keys brings real risks. A bad query can change live rows or pull sensitive user records. Teams need clear boundaries before they let an agent touch a live database.

How openhands azure sql works in practice

The agent runs inside a local or cloud workspace. It reads code, writes scripts, and runs database queries to check data or test changes. To talk to the database, the agent needs a valid login or user account.

In this database engine, a database user is the identity of a login when it connects. If an agent needs to reach many databases on one server, teams often use a login in the master database. If the agent only needs one database, a contained database user with a password works well. An admin must turn on contained databases on the server and database first. The database engine supports thirteen types of database users in total.

Once the user exists, an admin puts it in a fixed database role. All roles, including the public role, have basic connect rights. The permissions inside these fixed database roles cannot be changed. For safe read tasks, admins often pick the data reader role. Members of that role can read all data from all user tables and views. If the agent must change rows, admins add the data writer role. That role lets the user add, delete, or change data in all user tables.

Security tradeoffs of static roles and credentials

Fixed roles give a good starting point, but they have clear limits. A data reader role lets the agent read every user table and view. It does not hide private columns inside those tables. When the agent runs a query, the database returns raw emails, phone numbers, card numbers, and national IDs. That data then goes straight into the agent prompt and logs.

Static keys in the agent workspace also create risk. If an agent holds a password in a text file, a prompt bug might expose it. Worse, some teams give the agent the owner role to avoid permission errors. Members of the owner role can do all setup and maintenance tasks. They can even drop the whole database.

Azure RBAC + SQL Query Filtering: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Admins can use deny roles to block some actions. A deny data writer role stops a user from adding, changing, or deleting data. A deny data reader role stops a user from reading any user tables, views, or their metadata. Still, database roles work at the table and view level, not per query. They do not ask a human for approval before a risky command runs. They also do not rewrite sensitive fields in query results on the fly.

Managing query risk and data exposure

To keep live data safe, teams put controls between the AI workspace and the database. Instead of handing out raw passwords, teams route agent traffic through a central check point. This setup keeps secrets out of the agent container.

When the agent sends a query, policy checks can inspect the command before it runs. Read queries can pass through right away. Queries that change schemas or delete rows can pause for human review. At the same time, data masking can rewrite matched fields in results, such as card numbers or emails. The agent gets the structure it needs to debug code, while raw personal data stays protected.

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 database role should an AI coding agent use?

Start with the fixed data reader role so the agent can only read user tables and views. Add the deny data writer role if you want to block all data changes for sure.

Should an AI agent use a master login or a contained user?

Use a contained database user when the agent only needs one or a few databases. Use a login tied to the master database only when it must reach many databases on the server.

Does a read-only database role protect private customer fields?

No, the fixed data reader role allows reading all data across all user tables and views. To protect emails, phone numbers, or card numbers, you need a layer that rewrites matched fields in results.

The query runs. The emails stay hidden.