How to manage an Azure Cosmos DB account

Learn how to set global consistency, work with keys, and delete an Azure Cosmos DB account in the Azure portal.

Manage Azure Cosmos DB consistency settings

Selecting the right consistency level depends on the semantics of your application. Familiarize yourself with the available consistency levels in Azure Cosmos DB by reading Using consistency levels to maximize availability and performance in Azure Cosmos DB. Azure Cosmos DB provides consistency, availability, and performance guarantees, at every consistency level available for your database account. Configuring your database account with a consistency level of Strong requires that your data is confined to a single Azure region and not globally available. On the other hand, the relaxed consistency levels - bounded staleness, session, or eventual enable you to associate any number of Azure regions with your database account. The following simple steps show you how to select the default consistency level for your database account.

To specify the default consistency for an Azure Cosmos DB account

  1. In the Azure portal, access your Azure Cosmos DB account.
  2. In the account page, click Default consistency.
  3. In the Default Consistency page, select the new consistency level and click Save. Default consistency session

View, copy, and regenerate access keys

When you create an Azure Cosmos DB account, the service generates two master access keys that can be used for authentication when the Azure Cosmos DB account is accessed. By providing two access keys, Azure Cosmos DB enables you to regenerate the keys with no interruption to your Azure Cosmos DB account.

In the Azure portal, access the Keys page from the resource menu on the Azure Cosmos DB account page to view, copy, and regenerate the access keys that are used to access your Azure Cosmos DB account.

Azure portal screenshot, Keys page

Note

The Keys page also includes primary and secondary connection strings that can be used to connect to your account from the Data Migration Tool.

Read-only keys are also available on this page. Reads and queries are read-only operations, while creates, deletes, and replaces are not.

Copy an access key in the Azure portal

On the Keys page, click the Copy button to the right of the key you wish to copy.

View and copy an access key in the Azure portal, Keys page

Regenerate access keys

You should change the access keys to your Azure Cosmos DB account periodically to help keep your connections more secure. Two access keys are assigned to enable you to maintain connections to the Azure Cosmos DB account using one access key while you regenerate the other access key.

Warning

Regenerating your access keys affects any applications that are dependent on the current key. All clients that use the access key to access the Azure Cosmos DB account must be updated to use the new key.

If you have applications or cloud services using the Azure Cosmos DB account, you will lose the connections if you regenerate keys, unless you roll your keys. The following steps outline the process involved in rolling your keys.

  1. Update the access key in your application code to reference the secondary access key of the Azure Cosmos DB account.
  2. Regenerate the primary access key for your Azure Cosmos DB account. In the Azure portal, access your Azure Cosmos DB account.
  3. In the Azure Cosmos DB Account page, click Keys.
  4. On the Keys page, click the regenerate button, then click Ok to confirm that you want to generate a new key. Regenerate access keys
  5. Once you have verified that the new key is available for use (approximately five minutes after regeneration), update the access key in your application code to reference the new primary access key.
  6. Regenerate the secondary access key.

    Regenerate access keys

Note

It can take several minutes before a newly generated key can be used to access your Azure Cosmos DB account.

Get the connection string

To retrieve your connection string, do the following:

  1. In the Azure portal, access your Azure Cosmos DB account.
  2. In the resource menu, click Keys.
  3. Click the Copy button next to the Primary Connection String or Secondary Connection String box.

If you are using the connection string in the Azure Cosmos DB Database Migration Tool, append the database name to the end of the connection string. AccountEndpoint=< >;AccountKey=< >;Database=< >.

Delete an Azure Cosmos DB account

To remove an Azure Cosmos DB account from the Azure portal that you are no longer using, right-click the account name, and click Delete account.

How to delete an Azure Cosmos DB account in the Azure portal

  1. In the Azure portal, access the Azure Cosmos DB account you wish to delete.
  2. On the Azure Cosmos DB account page, right-click the account, and then click Delete Account.
  3. On the resulting confirmation page, type the Azure Cosmos DB account name to confirm that you want to delete the account.
  4. Click the Delete button.

How to delete an Azure Cosmos DB account in the Azure portal

Next steps

Learn how to get started with your Azure Cosmos DB account.