Azure CLI samples for Azure Cosmos DB

The following table includes links to sample Azure CLI scripts for Azure Cosmos DB. Reference pages for all Azure Cosmos DB CLI commands are available in the Azure CLI 2.0 Reference.

Create Azure Cosmos DB account, database, and containers
Create a DocumentDB API, Graph, or Table API account Creates a single Azure Cosmos DB API account, database, and container for use with the DocumentDB, Graph, or Table APIs.
Create a MongoDB API account Creates a single Azure Cosmos DB MongoDB API account, database, and collection.
Scale Azure Cosmos DB
Scale container throughput Changes the provisioned througput on a container.
Replicate Azure Cosmos DB database account in multiple regions and configure failover priorities Globally replicates account data into multiple regions with a specified failover priority.
Secure Azure Cosmos DB
Get account keys Gets the primary and secondary master write keys and primary and secondary read-only keys for the account.
Get MongoDB connection string Gets the connection string to connect your MongoDB app to your Azure Cosmos DB account.
Regenerate account keys Regenerates the master or read-only key for the account.
Create a firewall Creates an inbound IP access control policy to limit access to the account from an approved set of machines and/or cloud services.
High availability, disaster recovery, backup and restore
Configure failover policy Sets the failover priority of each region in which the account is replicated.
Connect Azure Cosmos DB to resources
Connect a web app to Azure Cosmos DB Create and connect an Azure Cosmos DB database and an Azure web app.