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

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

Cosmosdb account name.

--database-name -d

Database name.

--name -n

Collection name.

--resource-group -g

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

Optional Parameters

--analytical-storage-ttl

Analytical TTL, when analytical storage is enabled.

--idx

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

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

Sharding key path.

--throughput

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

Increase logging verbosity to show all debug logs.

--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

--output -o

Output format.

accepted values: json, jsonc, none, table, tsv, yaml, yamlc
default value: json
--query

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

--subscription

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

--verbose

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

az cosmosdb mongodb collection delete

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

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

Required Parameters

--account-name -a

Cosmosdb account name.

--database-name -d

Database name.

--name -n

Collection name.

--resource-group -g

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

Optional Parameters

--yes -y

Do not prompt for confirmation.

default value: False
Global Parameters
--debug

Increase logging verbosity to show all debug logs.

--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

--output -o

Output format.

accepted values: json, jsonc, none, table, tsv, yaml, yamlc
default value: json
--query

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

--subscription

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

--verbose

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

az cosmosdb mongodb collection exists

Checks if an Azure Cosmos DB MongoDB collection exists.

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

Required Parameters

--account-name -a

Cosmosdb account name.

--database-name -d

Database name.

--name -n

Collection name.

--resource-group -g

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

Global Parameters
--debug

Increase logging verbosity to show all debug logs.

--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

--output -o

Output format.

accepted values: json, jsonc, none, table, tsv, yaml, yamlc
default value: json
--query

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

--subscription

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

--verbose

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

az cosmosdb mongodb collection list

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

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

Required Parameters

--account-name -a

Cosmosdb account name.

--database-name -d

Database name.

--resource-group -g

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

Global Parameters
--debug

Increase logging verbosity to show all debug logs.

--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

--output -o

Output format.

accepted values: json, jsonc, none, table, tsv, yaml, yamlc
default value: json
--query

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

--subscription

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

--verbose

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

az cosmosdb mongodb collection merge

Preview

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

Name of the CosmosDB database account.

--database-name -d

Name of the mongoDB database.

--name -n

Name of the mongoDB collection.

--resource-group -g

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

Global Parameters
--debug

Increase logging verbosity to show all debug logs.

--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

--output -o

Output format.

accepted values: json, jsonc, none, table, tsv, yaml, yamlc
default value: json
--query

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

--subscription

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

--verbose

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

az cosmosdb mongodb collection redistribute-partition-throughput

Preview

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

Name of the CosmosDB database account.

--database-name -d

Name of the CosmosDB database name.

--name -n

Name of the CosmosDB collection.

--resource-group -g

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

Optional Parameters

--evenly-distribute

Switch to distribute throughput equally among all physical partitions.

accepted values: false, true
default value: False
--source-partition-info

Space separated source physical partition ids eg: 1 2.

default value: []
--target-partition-info

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

default value: []
Global Parameters
--debug

Increase logging verbosity to show all debug logs.

--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

--output -o

Output format.

accepted values: json, jsonc, none, table, tsv, yaml, yamlc
default value: json
--query

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

--subscription

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

--verbose

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

az cosmosdb mongodb collection restore

Restore a deleted mongodb collection within the same account.

az cosmosdb mongodb collection restore --account-name
                                       --database-name
                                       --name
                                       --resource-group
                                       [--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

Cosmosdb account name.

--database-name -d

Database name.

--name -n

Collection name.

--resource-group -g

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

Optional Parameters

--restore-timestamp -t

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

Global Parameters
--debug

Increase logging verbosity to show all debug logs.

--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

--output -o

Output format.

accepted values: json, jsonc, none, table, tsv, yaml, yamlc
default value: json
--query

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

--subscription

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

--verbose

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

az cosmosdb mongodb collection restore (cosmosdb-preview extension)

Preview

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

Cosmosdb account name.

--database-name -d

Database name.

--name -n

Collection name.

--resource-group -g

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

Optional Parameters

--disable-ttl
Preview

Enable or disable restoring with ttl disabled.

accepted values: false, true
--restore-timestamp -t

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

Global Parameters
--debug

Increase logging verbosity to show all debug logs.

--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

--output -o

Output format.

accepted values: json, jsonc, none, table, tsv, yaml, yamlc
default value: json
--query

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

--subscription

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

--verbose

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

az cosmosdb mongodb collection retrieve-partition-throughput

Preview

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

Name of the CosmosDB database account.

--database-name -d

Name of the CosmosDB database name.

--name -n

Name of the CosmosDB container.

--resource-group -g

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

Optional Parameters

--all-partitions

Switch to retrieve throughput for all physical partitions.

accepted values: false, true
default value: False
--physical-partition-ids -p

Space separated list of physical partition ids.

default value: []
Global Parameters
--debug

Increase logging verbosity to show all debug logs.

--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

--output -o

Output format.

accepted values: json, jsonc, none, table, tsv, yaml, yamlc
default value: json
--query

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

--subscription

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

--verbose

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

az cosmosdb mongodb collection show

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

Required Parameters

--account-name -a

Cosmosdb account name.

--database-name -d

Database name.

--name -n

Collection name.

--resource-group -g

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

Global Parameters
--debug

Increase logging verbosity to show all debug logs.

--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

--output -o

Output format.

accepted values: json, jsonc, none, table, tsv, yaml, yamlc
default value: json
--query

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

--subscription

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

--verbose

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

az cosmosdb mongodb collection update

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]

Required Parameters

--account-name -a

Cosmosdb account name.

--database-name -d

Database name.

--name -n

Collection name.

--resource-group -g

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

Optional Parameters

--analytical-storage-ttl

Analytical TTL, when analytical storage is enabled.

--idx

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

Increase logging verbosity to show all debug logs.

--help -h

Show this help message and exit.

--only-show-errors

Only show errors, suppressing warnings.

--output -o

Output format.

accepted values: json, jsonc, none, table, tsv, yaml, yamlc
default value: json
--query

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

--subscription

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

--verbose

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