How to Configure Cosmos DB Create User
You run a cosmos db create user workflow by assigning cloud identity roles or generating resource tokens. This setup grants specific read and write rights to your apps and engineers. Many teams skip this step at first and share primary master keys instead. Shared master keys give every user full control over all data containers. When roles are too broad, one bad query can delete production records or expose private data. How the cosmos db create user workflow operates The database engine hand
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 run a cosmos db create user workflow by assigning cloud identity roles or generating resource tokens. This setup grants specific read and write rights to your apps and engineers. Many teams skip this step at first and share primary master keys instead. Shared master keys give every user full control over all data containers. When roles are too broad, one bad query can delete production records or expose private data.
How the cosmos db create user workflow operates
The database engine handles user accounts in two distinct ways. First, you can create native database users inside a specific database account. These native users hold permissions that point to exact containers or partition keys. The database issues short-lived resource tokens for those permissions. Your app sends that token to read or write allowed items.
Second, teams can use cloud directory identities for data plane actions. You map an engineer or service principal to a custom data role. The cloud directory checks who the user is during login. Then the database checks the role definition to allow or block data actions. This setup avoids putting static master keys inside app config files.
Each method targets a different use case. Resource tokens work well when client apps need narrow item permissions. Cloud directory roles fit better when human engineers run queries from local tools. Both paths require an admin to define the scope before any user logs in.
What native user roles solve and what they miss
Native roles and directory mappings solve the basic login problem. They stop teams from handing out root account keys to every developer. You can restrict an engineer to read-only tasks on a single container. You can also cut off access by removing the user role mapping.
Still, native user creation only decides who can open a session. It does not inspect what individual queries do once the session starts. A user with read rights on a container can still pull every document inside it. Those documents often hold sensitive fields like emails, phone numbers, or card numbers.
User Provisioning (SCIM) + End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Native roles also lack step-by-step approval flows for risky write commands. If a developer has write rights to fix a bug, they keep those rights all day. Native database logs record high-level events, but teams struggle to tie each query to a person. Rotating native tokens and cleaning up stale user accounts also adds daily manual work.
Managing database sessions and sensitive data in flight
Securing a NoSQL store takes more than initial role setup. Teams need controls that work on every single query during the active session. When an engineer runs a read command, data masking should rewrite matched fields in results. This protects emails, phone numbers, and national IDs during live debugging.
Write actions also need tighter checks than static roles provide. Instead of permanent write roles, engineers can request approval for one specific task. Auditors also need clear logs that show the exact user and query text. Combining identity checks with query-level controls closes the gap left by basic user roles.
Govern statements and responses across databases and APIs
Good config and scoped roles are needed setup. They do not check single queries in flight or mask sensitive fields in returned rows. Across Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, and internal HTTP endpoints, hoop.dev sits inline in the protocol beside each supported service as an open-source proxy, a sidecar for your database or API. For every query or command an AI agent or engineer runs against production, hoop.dev decides to pass, mask, block, or hold it for human approval.
First, hoop.dev guardrails block banned queries before they run or hold risky ones for review, and hoop.dev data masking rewrites matched sensitive values in responses in memory. Furthermore, hoop.dev holds SOC 2 Type II and is open source on GitHub.
Frequently asked questions
What is the difference between a native user and a role assignment?
A native database user uses permissions and tokens managed inside the database engine itself. A role assignment links an external cloud directory identity to data plane actions.
Can a cosmos db create user setup restrict access to one partition key?
Yes, native permissions and resource tokens can limit read or write tasks to a specific partition key. This keeps a user from reading data that belongs to other tenants.
Why should teams avoid using primary master keys for daily queries?
Master keys bypass all container restrictions and grant full admin control over the account. If a master key leaks, an attacker can read or delete every database container.
Related guides
In this post