Azure PowerShell samples for Azure Cosmos DB MongoDB API

The following table includes links to sample Azure PowerShell scripts for Azure Cosmos DB for MongoDB API.


Currently you can only create 3.2 version (that is, accounts using the endpoint in the format * of Azure Cosmos DB's API for MongoDB accounts by using PowerShell, CLI, and Resource Manager templates. To create 3.6 version of accounts, use Azure portal instead.


The samples use Az.CosmosDB management cmdlets. Please check for updates to Az.CosmosDB regularly.

Task Description
Create an account, database and collection Creates an Azure Cosmos account, database and collection.
List or get databases or collections List or get database or collection.
Get RU/s Get RU/s for a database or collection.
Update RU/s Update RU/s for a database or collection.
Update an account or add a region Add a region to a Cosmos account. Can also be used to modify other account properties but these must be separate from changes to 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 account.
Create a Cosmos Account with IP Firewall Create an Azure Cosmos account with IP Firewall enabled.
Lock resources from deletion Prevent resources from being deleted with resource locks.