Azure CLI samples for Azure Cosmos DB Core (SQL) API

APPLIES TO: SQL API

The following table includes links to sample Azure CLI scripts for Azure Cosmos DB. Use the links on the right to navigate to API specific samples. Common samples are the same across all APIs. Reference pages for all Azure Cosmos DB CLI commands are available in the Azure CLI Reference. Azure Cosmos DB CLI script samples can also be found in the Azure Cosmos DB CLI GitHub Repository.

These samples require Azure CLI version 2.12.1 or later. Run az --version to find the version. If you need to install or upgrade, see Install Azure CLI

For Azure CLI samples for other APIs see CLI Samples for Cassandra, CLI Samples for MongoDB API, CLI Samples for Gremlin, CLI Samples for Table

Common Samples

These samples apply to all Azure Cosmos DB APIs

Task Description
Add or failover regions Add a region, change failover priority, trigger a manual failover.
Account keys and connection strings  List account keys, read-only keys, regenerate keys and list connection strings.
Secure with IP firewall Create a Cosmos account with IP firewall configured.
Secure new account with service endpoints Create a Cosmos account and secure with service-endpoints.
Secure existing account with service endpoints Update a Cosmos account to secure with service-endpoints when the subnet is eventually configured.

Core (SQL) API Samples

Task Description
Create an Azure Cosmos account, database and container Creates an Azure Cosmos DB account, database, and container for Core (SQL) API.
Create an Azure Cosmos account, database and container with autoscale Creates an Azure Cosmos DB account, database, and container with autoscale for Core (SQL) API.
Throughput operations Read, update and migrate between autoscale and standard throughput on a database and container.
Lock resources from deletion Prevent resources from being deleted with resource locks.