Azure PowerShell samples for Azure Cosmos DB

The following table includes links to commonly used Azure PowerShell 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 PowerShell cmdlets are available in the Azure PowerShell Reference. Please check for updates to Az.CosmosDB regularly. You can also fork these PowerShell samples for Cosmos DB from our GitHub repository, Cosmos DB PowerShell Samples on GitHub.

Common Samples

Task Description
Update an account Update a Cosmos DB account's default consistency level.
Update an account's regions Update a Cosmos DB account's regions.
Change failover priority or trigger failover Change the regional failover priority of an Azure Cosmos account or trigger a manual failover.
Account keys or connection strings Get primary and secondary keys, connection strings or regenerate an account key of an Azure Cosmos DB account.
Create a Cosmos Account with IP Firewall Create an Azure Cosmos DB account with IP Firewall enabled.

Core (SQL) API Samples

Task Description
Create an account, database and container Create an Azure Cosmos DB account, database and container.
Create an account, database and container with autoscale Create an Azure Cosmos DB account, database and container with autoscale.
Create a container with a large partition key Create a container with a large partition key.
Create a container with no index policy Create an Azure Cosmos container with index policy turned off.
List or get databases or containers List or get database or containers.
Get throughput Get throughput for a database or container.
Update throughput Update throughput for a database or container.
Lock resources from deletion Prevent resources from being deleted with resource locks.

Cassandra API Samples

Task Description
Create an account, keyspace and table Creates an Azure Cosmos account, keyspace and table.
Create an account, keyspace and table with autoscale Creates an Azure Cosmos account, keyspace and table with autoscale.
List or get keyspaces or tables List or get keyspaces or tables.
Get throughput Get throughput for a keyspace or table.
Update throughput Update throughput for a keyspace or table.
Lock resources from deletion Prevent resources from being deleted with resource locks.

Mongo DB API Samples

Task Description
Create an account, database and collection Creates an Azure Cosmos account, database and collection.
Create an account, database and collection with autoscale Creates an Azure Cosmos account, database and collection with autoscale.
List or get databases or collections List or get database or collection.
Get throughput Get throughput for a database or collection.
Update throughput Update throughput for a database or collection.
Lock resources from deletion Prevent resources from being deleted with resource locks.

Gremlin API Samples

Task Description
Create an account, database and graph Creates an Azure Cosmos account, database and graph.
Create an account, database and graph with autoscale Creates an Azure Cosmos account, database and graph with autoscale.
List or get databases or graphs List or get database or graph.
Get throughput Get throughput for a database or graph.
Update throughput Update throughput for a database or graph.
Lock resources from deletion Prevent resources from being deleted with resource locks.

Table API Samples

Task Description
Create an account and table Creates an Azure Cosmos account and table.
Create an account and table with autoscale Creates an Azure Cosmos account and table autoscale.
List or get tables List or get tables.
Get throughput Get throughput for a table.
Update throughput Update throughput for a table.
Lock resources from deletion Prevent resources from being deleted with resource locks.