Azure CLI samples for Azure Cosmos DB API for MongoDB
APPLIES TO:
Azure Cosmos DB API for MongoDB
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.30 or later. Run az --version to find the version. If you need to install or upgrade, see Install Azure CLI
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. |
MongoDB API Samples
| Task | Description |
|---|---|
| Create an Azure Cosmos account, database and collection | Creates an Azure Cosmos DB account, database, and collection for MongoDB API. |
| Create a serverless Azure Cosmos account, database and collection | Creates a serverless Azure Cosmos DB account, database, and collection for MongoDB API. |
| Create an Azure Cosmos account, database with autoscale and two collections with shared throughput | Creates an Azure Cosmos DB account, database with autoscale and two collections with shared throughput for MongoDB API. |
| Throughput operations | Read, update and migrate between autoscale and standard throughput on a database and collection. |
| Lock resources from deletion | Prevent resources from being deleted with resource locks. |
Next steps
Trying to do capacity planning for a migration to Azure Cosmos DB? You can use information about your existing database cluster for capacity planning.
- If all you know is the number of vcores and servers in your existing database cluster, read about estimating request units using vCores or vCPUs
- If you know typical request rates for your current database workload, read about estimating request units using Azure Cosmos DB capacity planner