How to Create Credentials in Azure SQL Database
To understand how to create credentials in Azure SQL Database, you must pick an account type. You set up either a server login with a user or a contained user. A database user is the identity of a login inside a single database. You then assign that user to a fixed role to control read and write access. This two-step setup keeps server rules separate from local database data. How to create credentials in Azure SQL Database in practice In Microsoft SQL engines, you have two main paths for new
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.
To understand how to create credentials in Azure SQL Database, you must pick an account type. You set up either a server login with a user or a contained user.
A database user is the identity of a login inside a single database. You then assign that user to a fixed role to control read and write access. This two-step setup keeps server rules separate from local database data.
How to create credentials in Azure SQL Database in practice
In Microsoft SQL engines, you have two main paths for new accounts. If someone needs many databases on one instance, use a login in the master database. You then create a database user inside each target database tied to that login.
If an engineer or AI agent needs only one database, use a contained user. A contained database user has its own password inside the target database. It does not tie back to a login in the master database. An admin must enable contained databases on the server and the database first.
Overall, the engine supports thirteen types of database users for different login needs. Once the user exists, you grant rights by adding that user to a role. All roles, including the public role, have basic rights to connect. You cannot change the built-in permissions assigned to fixed database roles.
Assigning fixed roles for read and write control
Most teams start by giving new users read-only rights to keep production safe. Members of the db_datareader role can read all data from all user tables and views. If a user needs to change rows, you add the db_datawriter role. Members of db_datawriter can add, delete, or change data in all user tables.
You can also block access explicitly with deny roles. Members of db_denydatareader cannot read any data from user tables, views, or their metadata. Members of db_denydatawriter cannot add, modify, or delete any table data.
Database Credential Rotation + Just-in-Time Access: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
At the top level sits the db_owner role. A member of db_owner can run all maintenance tasks and even drop the database. Admins add users to these roles with standard role alteration statements. In Azure Synapse, admins use a stored procedure to add role members instead.
Security tradeoffs of static database credentials
Creating logins and assigning fixed roles is a solid first step for access control. Still, static passwords and broad roles leave big gaps during an active session. Once an engineer or AI agent logs in, role checks happen at the table level.
A user in db_datareader can read all column in every user table by default. If a table holds emails, phone numbers, card numbers, or national IDs, queries return them. Standard database roles do not rewrite matched fields in results on the fly.
Shared logins also make it hard to track who ran a specific query. If three engineers share one SQL password, the audit log shows only one user name. Sharing passwords in chat tools or local files also raises the risk of leaks. Rotating those passwords often breaks scripts and apps that rely on them.
Teams also struggle when an engineer needs a quick fix in production. Granting db_datawriter gives wide write rights across all user tables at once. Without query-level approval, a small typo in a statement can delete thousands of rows.
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 SQL login and a database user?
A login lives in the master database and lets a person reach the server. A database user is the identity of that login inside one specific database. You can also create a contained user with a password directly inside one database.
How do I give an account read-only access to all tables?
Create the database user and add it to the db_datareader fixed role. Members of db_datareader can read all data from all user tables and views. To block writes for sure, you can also add the user to db_denydatawriter.
Can I customize the permissions of fixed database roles?
No, the permissions assigned to fixed database roles cannot be changed. Roles like db_owner, db_datareader, and db_datawriter have locked permission sets. If you need custom table rules, you must create your own user-defined role.
Related guides
In this post