Share via


az cosmosdb mongodb collection

Note

This command group has commands that are defined in both Azure CLI and at least one extension. Install each extension to benefit from its extended capabilities. Learn more about extensions.

Manage Azure Cosmos DB MongoDB collections.

Commands

Name Description Type Status
az cosmosdb mongodb collection create

Create an MongoDB collection under an Azure Cosmos DB MongoDB database.

Core GA
az cosmosdb mongodb collection delete

Delete the MongoDB collection under an Azure Cosmos DB MongoDB database.

Core GA
az cosmosdb mongodb collection exists

Checks if an Azure Cosmos DB MongoDB collection exists.

Core GA
az cosmosdb mongodb collection list

List the MongoDB collections under an Azure Cosmos DB MongoDB database.

Core GA
az cosmosdb mongodb collection merge

Merges the partitions of a mongodb collection.

Extension Preview
az cosmosdb mongodb collection redistribute-partition-throughput

Redistributes the partition throughput of a mongodb collection.

Extension Preview
az cosmosdb mongodb collection restore

Restore a deleted mongodb collection within the same account.

Core GA
az cosmosdb mongodb collection restore (cosmosdb-preview extension)

Restore a deleted mongodb collection within the same account.

Extension Preview
az cosmosdb mongodb collection retrieve-partition-throughput

Retrieve the partition throughput of a mongodb collection.

Extension Preview
az cosmosdb mongodb collection show

Show the details of a MongoDB collection under an Azure Cosmos DB MongoDB database.

Core GA
az cosmosdb mongodb collection throughput

Manage throughput of MongoDB collection under an Azure Cosmos DB account.

Core GA
az cosmosdb mongodb collection throughput migrate

Migrate the throughput of the MongoDB collection between autoscale and manually provisioned.

Core GA
az cosmosdb mongodb collection throughput show

Get the throughput of the MongoDB collection under an Azure Cosmos DB MongoDB database.

Core GA
az cosmosdb mongodb collection throughput update

Update the throughput of the MongoDB collection under an Azure Cosmos DB MongoDB database.

Core GA
az cosmosdb mongodb collection update

Update an MongoDB collection under an Azure Cosmos DB MongoDB database.

Core GA

az cosmosdb mongodb collection create

Experimental Preview Deprecated

Create an MongoDB collection under an Azure Cosmos DB MongoDB database.

az cosmosdb mongodb collection create --account-name
                                      --database-name
                                      --name
                                      --resource-group
                                      [--analytical-storage-ttl]
                                      [--idx]
                                      [--max-throughput]
                                      [--shard]
                                      [--throughput]

Examples

Create an Azure Cosmos DB MongoDB collection.

az cosmosdb mongodb collection create -g MyResourceGroup -a MyAccount -d MyDatabase -n MyCollection --shard "ShardingKey" --idx @indexes-file.json --throughput "500"

Required Parameters

--account-name -a
Experimental Preview Deprecated

Cosmosdb account name.

--database-name -d
Experimental Preview Deprecated

Database name.

--name -n
Experimental Preview Deprecated

Collection name.

--resource-group -g
Experimental Preview Deprecated

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

Optional Parameters

--analytical-storage-ttl
Experimental Preview Deprecated

Analytical TTL, when analytical storage is enabled.

--idx
Experimental Preview Deprecated

Indexes, you can enter it as a string or as a file, e.g., --idx @indexes-file.json or --idx "[{"key": {"keys": ["_ts"]},"options": {"expireAfterSeconds": 1000}}, {"key": {"keys": ["user_id", "user_address"]}, "options": {"unique": "true"}}]".

--max-throughput
Experimental Preview Deprecated

The maximum throughput resource can scale to (RU/s). Provided when the resource is autoscale enabled. The minimum value can be 4000 (RU/s).

--shard
Experimental Preview Deprecated

Sharding key path.

--throughput
Experimental Preview Deprecated

The throughput of MongoDB collection (RU/s). Default value is 400. Omit this parameter if the database has shared throughput unless the collection should have dedicated throughput.

Global Parameters
--debug
Experimental Preview Deprecated

Increase logging verbosity to show all debug logs.

--help -h
Experimental Preview Deprecated

Show this help message and exit.

--only-show-errors
Experimental Preview Deprecated

Only show errors, suppressing warnings.

--output -o
Experimental Preview Deprecated

Output format.

Accepted values: json, jsonc, none, table, tsv, yaml, yamlc
Default value: json
--query
Experimental Preview Deprecated

JMESPath query string. See http://jmespath.org/ for more information and examples.

--subscription
Experimental Preview Deprecated

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--verbose
Experimental Preview Deprecated

Increase logging verbosity. Use --debug for full debug logs.

az cosmosdb mongodb collection delete

Experimental Preview Deprecated

Delete the MongoDB collection under an Azure Cosmos DB MongoDB database.

az cosmosdb mongodb collection delete --account-name
                                      --database-name
                                      --name
                                      --resource-group
                                      [--yes]

Examples

Required Parameters

--account-name -a
Experimental Preview Deprecated

Cosmosdb account name.

--database-name -d
Experimental Preview Deprecated

Database name.

--name -n
Experimental Preview Deprecated

Collection name.

--resource-group -g
Experimental Preview Deprecated

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

Optional Parameters

--yes -y
Experimental Preview Deprecated

Do not prompt for confirmation.

Default value: False
Global Parameters
--debug
Experimental Preview Deprecated

Increase logging verbosity to show all debug logs.

--help -h
Experimental Preview Deprecated

Show this help message and exit.

--only-show-errors
Experimental Preview Deprecated

Only show errors, suppressing warnings.

--output -o
Experimental Preview Deprecated

Output format.

Accepted values: json, jsonc, none, table, tsv, yaml, yamlc
Default value: json
--query
Experimental Preview Deprecated

JMESPath query string. See http://jmespath.org/ for more information and examples.

--subscription
Experimental Preview Deprecated

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--verbose
Experimental Preview Deprecated

Increase logging verbosity. Use --debug for full debug logs.

az cosmosdb mongodb collection exists

Experimental Preview Deprecated

Checks if an Azure Cosmos DB MongoDB collection exists.

az cosmosdb mongodb collection exists --account-name
                                      --database-name
                                      --name
                                      --resource-group

Examples

Required Parameters

--account-name -a
Experimental Preview Deprecated

Cosmosdb account name.

--database-name -d
Experimental Preview Deprecated

Database name.

--name -n
Experimental Preview Deprecated

Collection name.

--resource-group -g
Experimental Preview Deprecated

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

Optional Parameters

Global Parameters
--debug
Experimental Preview Deprecated

Increase logging verbosity to show all debug logs.

--help -h
Experimental Preview Deprecated

Show this help message and exit.

--only-show-errors
Experimental Preview Deprecated

Only show errors, suppressing warnings.

--output -o
Experimental Preview Deprecated

Output format.

Accepted values: json, jsonc, none, table, tsv, yaml, yamlc
Default value: json
--query
Experimental Preview Deprecated

JMESPath query string. See http://jmespath.org/ for more information and examples.

--subscription
Experimental Preview Deprecated

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--verbose
Experimental Preview Deprecated

Increase logging verbosity. Use --debug for full debug logs.

az cosmosdb mongodb collection list

Experimental Preview Deprecated

List the MongoDB collections under an Azure Cosmos DB MongoDB database.

az cosmosdb mongodb collection list --account-name
                                    --database-name
                                    --resource-group

Examples

Required Parameters

--account-name -a
Experimental Preview Deprecated

Cosmosdb account name.

--database-name -d
Experimental Preview Deprecated

Database name.

--resource-group -g
Experimental Preview Deprecated

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

Optional Parameters

Global Parameters
--debug
Experimental Preview Deprecated

Increase logging verbosity to show all debug logs.

--help -h
Experimental Preview Deprecated

Show this help message and exit.

--only-show-errors
Experimental Preview Deprecated

Only show errors, suppressing warnings.

--output -o
Experimental Preview Deprecated

Output format.

Accepted values: json, jsonc, none, table, tsv, yaml, yamlc
Default value: json
--query
Experimental Preview Deprecated

JMESPath query string. See http://jmespath.org/ for more information and examples.

--subscription
Experimental Preview Deprecated

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--verbose
Experimental Preview Deprecated

Increase logging verbosity. Use --debug for full debug logs.

az cosmosdb mongodb collection merge

Experimental Preview Deprecated

This command is in preview and under development. Reference and support levels: https://aka.ms/CLI_refstatus

Merges the partitions of a mongodb collection.

az cosmosdb mongodb collection merge --account-name
                                     --database-name
                                     --name
                                     --resource-group

Examples

merge partitions of collection my-mongodb-collection

az cosmosdb mongodb collection merge -g my-resource-group -a my-account -d my-db --name my-mongodb-collection

Required Parameters

--account-name -a
Experimental Preview Deprecated

Name of the CosmosDB database account.

--database-name -d
Experimental Preview Deprecated

Name of the mongoDB database.

--name -n
Experimental Preview Deprecated

Name of the mongoDB collection.

--resource-group -g
Experimental Preview Deprecated

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

Optional Parameters

Global Parameters
--debug
Experimental Preview Deprecated

Increase logging verbosity to show all debug logs.

--help -h
Experimental Preview Deprecated

Show this help message and exit.

--only-show-errors
Experimental Preview Deprecated

Only show errors, suppressing warnings.

--output -o
Experimental Preview Deprecated

Output format.

Accepted values: json, jsonc, none, table, tsv, yaml, yamlc
Default value: json
--query
Experimental Preview Deprecated

JMESPath query string. See http://jmespath.org/ for more information and examples.

--subscription
Experimental Preview Deprecated

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--verbose
Experimental Preview Deprecated

Increase logging verbosity. Use --debug for full debug logs.

az cosmosdb mongodb collection redistribute-partition-throughput

Experimental Preview Deprecated

This command is in preview and under development. Reference and support levels: https://aka.ms/CLI_refstatus

Redistributes the partition throughput of a mongodb collection.

az cosmosdb mongodb collection redistribute-partition-throughput --account-name
                                                                 --database-name
                                                                 --name
                                                                 --resource-group
                                                                 [--evenly-distribute {false, true}]
                                                                 [--source-partition-info]
                                                                 [--target-partition-info]

Examples

Evenly distributes the partition throughput for a mongodb collection among all physical partitions

az cosmosdb mongodb collection redistribute-partition-throughput --account-name account_name --database-name db_name --name container_name  --resource-group rg_name --evenly-distribute

Redistributes the partition throughput for a mongodb collection from source partitions to target partitions

az cosmosdb mongodb collection redistribute-partition-throughput --account-name account_name --database-name db_name --name container_name  --resource-group rg_name --target-partition-info 8=1200 6=1200' --source-partition-info 9'

Required Parameters

--account-name -a
Experimental Preview Deprecated

Name of the CosmosDB database account.

--database-name -d
Experimental Preview Deprecated

Name of the CosmosDB database name.

--name -n
Experimental Preview Deprecated

Name of the CosmosDB collection.

--resource-group -g
Experimental Preview Deprecated

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

Optional Parameters

--evenly-distribute
Experimental Preview Deprecated

Switch to distribute throughput equally among all physical partitions.

Accepted values: false, true
Default value: False
--source-partition-info
Experimental Preview Deprecated

Space separated source physical partition ids eg: 1 2.

Default value: []
--target-partition-info
Experimental Preview Deprecated

Information about desired target physical partition throughput eg: '0=1200 1=1200'.

Default value: []
Global Parameters
--debug
Experimental Preview Deprecated

Increase logging verbosity to show all debug logs.

--help -h
Experimental Preview Deprecated

Show this help message and exit.

--only-show-errors
Experimental Preview Deprecated

Only show errors, suppressing warnings.

--output -o
Experimental Preview Deprecated

Output format.

Accepted values: json, jsonc, none, table, tsv, yaml, yamlc
Default value: json
--query
Experimental Preview Deprecated

JMESPath query string. See http://jmespath.org/ for more information and examples.

--subscription
Experimental Preview Deprecated

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--verbose
Experimental Preview Deprecated

Increase logging verbosity. Use --debug for full debug logs.

az cosmosdb mongodb collection restore

Experimental Preview Deprecated

Restore a deleted mongodb collection within the same account.

az cosmosdb mongodb collection restore --account-name
                                       --database-name
                                       --name
                                       --resource-group
                                       [--disable-ttl]
                                       [--restore-timestamp]

Examples

Restore a deleted mongodb collection within the same account.

az cosmosdb mongodb collection restore --resource-group resource_group --account-name database_account_name --database-name parent_database_name --name name_of_collection_needs_to_be_restored --restore-timestamp 2020-07-13T16:03:41+0000

Required Parameters

--account-name -a
Experimental Preview Deprecated

Cosmosdb account name.

--database-name -d
Experimental Preview Deprecated

Database name.

--name -n
Experimental Preview Deprecated

Collection name.

--resource-group -g
Experimental Preview Deprecated

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

Optional Parameters

--disable-ttl
Experimental Preview Deprecated

Flag to restore with TTL disabled.

Usage: --disable-ttl True Default: false.

--restore-timestamp -t
Experimental Preview Deprecated

The timestamp to which the collection needs to be restored to.

Global Parameters
--debug
Experimental Preview Deprecated

Increase logging verbosity to show all debug logs.

--help -h
Experimental Preview Deprecated

Show this help message and exit.

--only-show-errors
Experimental Preview Deprecated

Only show errors, suppressing warnings.

--output -o
Experimental Preview Deprecated

Output format.

Accepted values: json, jsonc, none, table, tsv, yaml, yamlc
Default value: json
--query
Experimental Preview Deprecated

JMESPath query string. See http://jmespath.org/ for more information and examples.

--subscription
Experimental Preview Deprecated

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--verbose
Experimental Preview Deprecated

Increase logging verbosity. Use --debug for full debug logs.

az cosmosdb mongodb collection restore (cosmosdb-preview extension)

Experimental Preview Deprecated

This command is in preview and under development. Reference and support levels: https://aka.ms/CLI_refstatus

Restore a deleted mongodb collection within the same account.

az cosmosdb mongodb collection restore --account-name
                                       --database-name
                                       --name
                                       --resource-group
                                       [--disable-ttl {false, true}]
                                       [--restore-timestamp]

Examples

Restore a deleted mongodb collection within the same account.

az cosmosdb mongodb collection restore --resource-group resource_group --account-name database_account_name --database-name parent_database_name --name name_of_collection_needs_to_be_restored --restore-timestamp 2020-07-13T16:03:41+0000

Required Parameters

--account-name -a
Experimental Preview Deprecated

Cosmosdb account name.

--database-name -d
Experimental Preview Deprecated

Database name.

--name -n
Experimental Preview Deprecated

Collection name.

--resource-group -g
Experimental Preview Deprecated

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

Optional Parameters

--disable-ttl
Experimental Preview Deprecated

Enable or disable restoring with ttl disabled.

Accepted values: false, true
--restore-timestamp -t
Experimental Preview Deprecated

The timestamp to which the collection needs to be restored to.

Global Parameters
--debug
Experimental Preview Deprecated

Increase logging verbosity to show all debug logs.

--help -h
Experimental Preview Deprecated

Show this help message and exit.

--only-show-errors
Experimental Preview Deprecated

Only show errors, suppressing warnings.

--output -o
Experimental Preview Deprecated

Output format.

Accepted values: json, jsonc, none, table, tsv, yaml, yamlc
Default value: json
--query
Experimental Preview Deprecated

JMESPath query string. See http://jmespath.org/ for more information and examples.

--subscription
Experimental Preview Deprecated

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--verbose
Experimental Preview Deprecated

Increase logging verbosity. Use --debug for full debug logs.

az cosmosdb mongodb collection retrieve-partition-throughput

Experimental Preview Deprecated

This command is in preview and under development. Reference and support levels: https://aka.ms/CLI_refstatus

Retrieve the partition throughput of a mongodb collection.

az cosmosdb mongodb collection retrieve-partition-throughput --account-name
                                                             --database-name
                                                             --name
                                                             --resource-group
                                                             [--all-partitions {false, true}]
                                                             [--physical-partition-ids]

Examples

Retrieve container container_name's throughput for specific physical partitions

az cosmosdb mongodb collection retrieve-partition-throughput --account-name account_name --database-name db_name --name container_name  --resource-group rg_name --physical-partition-ids 8 9

Retrieve container container_name's throughput for all physical partitions

az cosmosdb mongodb collection retrieve-partition-throughput --account-name account_name --database-name db_name --name container_name  --resource-group rg_name --all-partitions

Required Parameters

--account-name -a
Experimental Preview Deprecated

Name of the CosmosDB database account.

--database-name -d
Experimental Preview Deprecated

Name of the CosmosDB database name.

--name -n
Experimental Preview Deprecated

Name of the CosmosDB container.

--resource-group -g
Experimental Preview Deprecated

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

Optional Parameters

--all-partitions
Experimental Preview Deprecated

Switch to retrieve throughput for all physical partitions.

Accepted values: false, true
Default value: False
--physical-partition-ids -p
Experimental Preview Deprecated

Space separated list of physical partition ids.

Default value: []
Global Parameters
--debug
Experimental Preview Deprecated

Increase logging verbosity to show all debug logs.

--help -h
Experimental Preview Deprecated

Show this help message and exit.

--only-show-errors
Experimental Preview Deprecated

Only show errors, suppressing warnings.

--output -o
Experimental Preview Deprecated

Output format.

Accepted values: json, jsonc, none, table, tsv, yaml, yamlc
Default value: json
--query
Experimental Preview Deprecated

JMESPath query string. See http://jmespath.org/ for more information and examples.

--subscription
Experimental Preview Deprecated

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--verbose
Experimental Preview Deprecated

Increase logging verbosity. Use --debug for full debug logs.

az cosmosdb mongodb collection show

Experimental Preview Deprecated

Show the details of a MongoDB collection under an Azure Cosmos DB MongoDB database.

az cosmosdb mongodb collection show --account-name
                                    --database-name
                                    --name
                                    --resource-group

Examples

Required Parameters

--account-name -a
Experimental Preview Deprecated

Cosmosdb account name.

--database-name -d
Experimental Preview Deprecated

Database name.

--name -n
Experimental Preview Deprecated

Collection name.

--resource-group -g
Experimental Preview Deprecated

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

Optional Parameters

Global Parameters
--debug
Experimental Preview Deprecated

Increase logging verbosity to show all debug logs.

--help -h
Experimental Preview Deprecated

Show this help message and exit.

--only-show-errors
Experimental Preview Deprecated

Only show errors, suppressing warnings.

--output -o
Experimental Preview Deprecated

Output format.

Accepted values: json, jsonc, none, table, tsv, yaml, yamlc
Default value: json
--query
Experimental Preview Deprecated

JMESPath query string. See http://jmespath.org/ for more information and examples.

--subscription
Experimental Preview Deprecated

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--verbose
Experimental Preview Deprecated

Increase logging verbosity. Use --debug for full debug logs.

az cosmosdb mongodb collection update

Experimental Preview Deprecated

Update an MongoDB collection under an Azure Cosmos DB MongoDB database.

az cosmosdb mongodb collection update --account-name
                                      --database-name
                                      --name
                                      --resource-group
                                      [--analytical-storage-ttl]
                                      [--idx]

Examples

Required Parameters

--account-name -a
Experimental Preview Deprecated

Cosmosdb account name.

--database-name -d
Experimental Preview Deprecated

Database name.

--name -n
Experimental Preview Deprecated

Collection name.

--resource-group -g
Experimental Preview Deprecated

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

Optional Parameters

--analytical-storage-ttl
Experimental Preview Deprecated

Analytical TTL, when analytical storage is enabled.

--idx
Experimental Preview Deprecated

Indexes, you can enter it as a string or as a file, e.g., --idx @indexes-file.json or --idx "[{"key": {"keys": ["_ts"]},"options": {"expireAfterSeconds": 1000}}, {"key": {"keys": ["user_id", "user_address"]}, "options": {"unique": "true"}}]".

Global Parameters
--debug
Experimental Preview Deprecated

Increase logging verbosity to show all debug logs.

--help -h
Experimental Preview Deprecated

Show this help message and exit.

--only-show-errors
Experimental Preview Deprecated

Only show errors, suppressing warnings.

--output -o
Experimental Preview Deprecated

Output format.

Accepted values: json, jsonc, none, table, tsv, yaml, yamlc
Default value: json
--query
Experimental Preview Deprecated

JMESPath query string. See http://jmespath.org/ for more information and examples.

--subscription
Experimental Preview Deprecated

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--verbose
Experimental Preview Deprecated

Increase logging verbosity. Use --debug for full debug logs.