Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
APPLIES TO:
NoSQL
MongoDB
Cassandra
Gremlin
Table
Primary/secondary keys provide access to all the administrative resources for the database account. Primary/secondary keys:
- Provide access to accounts, databases, users, and permissions.
- Can't be used to provide granular access to containers and documents.
- Are created during the creation of an account.
- Can be regenerated at any time.
Warning
Microsoft recommends that you use the most secure authentication flow available. The authentication flow described in this procedure requires a very high degree of trust in the application, and carries risks that are not present in other flows. You should only use this flow when other more secure flows, such as managed identities, aren't viable.
For Azure Cosmos DB, Microsoft Entra authentication is the most secure authentication mechanism available. Review the appropriate security guide for your API:
Each account consists of two keys: a primary key and a secondary key. The purpose of dual keys is so that you can regenerate, or roll, keys, providing continuous access to your account and data.
Primary/secondary keys come in two versions: read-write and read-only. The read-only keys only allow read operations on the account. They don't provide access to read permissions resources.
Prerequisites
- An existing Azure Cosmos DB account
Get your primary key
The primary key can usually be located using the Azure portal or through automation.
Use the Azure portal to obtain either of the four built-in keys:
- Primary read-write
- Primary read-only
- Secondary read-write
- Secondary read-only
Sign in to the Azure portal (https://portal.azure.com).
Navigate to your existing Azure Cosmos DB account.
In the account resource pane, select Keys from the Settings section of the service menu.
Locate and record the value of the Primary Key or Secondary Key fields in either the Read-write Keys or Read-only section.
Tip
You may need to show the keys before recording their values. By default, the keys are hidden.