你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

az cosmosdb mongodb collection

注意

此命令组具有在 Azure CLI 和至少一个扩展中定义的命令。 安装每个扩展,使其受益于其扩展功能。 详细了解扩展。

管理 Azure Cosmos DB MongoDB 集合。

命令

名称 说明 类型 状态
az cosmosdb mongodb collection create

在 Azure Cosmos DB MongoDB 数据库下创建 MongoDB 集合。

核心 GA
az cosmosdb mongodb collection delete

删除 Azure Cosmos DB MongoDB 数据库下的 MongoDB 集合。

核心 GA
az cosmosdb mongodb collection exists

检查 Azure Cosmos DB MongoDB 集合是否存在。

核心 GA
az cosmosdb mongodb collection list

列出 Azure Cosmos DB MongoDB 数据库下的 MongoDB 集合。

核心 GA
az cosmosdb mongodb collection merge

合并 mongodb 集合的分区。

扩展 预览
az cosmosdb mongodb collection redistribute-partition-throughput

重新分发 mongodb 集合的分区吞吐量。

扩展 预览
az cosmosdb mongodb collection restore

在同一帐户中还原已删除的 mongodb 集合。

核心 GA
az cosmosdb mongodb collection restore (cosmosdb-preview 扩展)

在同一帐户中还原已删除的 mongodb 集合。

扩展 预览
az cosmosdb mongodb collection retrieve-partition-throughput

检索 mongodb 集合的分区吞吐量。

扩展 预览
az cosmosdb mongodb collection show

显示 Azure Cosmos DB MongoDB 数据库下 MongoDB 集合的详细信息。

核心 GA
az cosmosdb mongodb collection throughput

在 Azure Cosmos DB 帐户下管理 MongoDB 集合的吞吐量。

核心 GA
az cosmosdb mongodb collection throughput migrate

在自动缩放和手动预配之间迁移 MongoDB 集合的吞吐量。

核心 GA
az cosmosdb mongodb collection throughput show

获取 Azure Cosmos DB MongoDB 数据库下的 MongoDB 集合的吞吐量。

核心 GA
az cosmosdb mongodb collection throughput update

更新 Azure Cosmos DB MongoDB 数据库下 MongoDB 集合的吞吐量。

核心 GA
az cosmosdb mongodb collection update

在 Azure Cosmos DB MongoDB 数据库下更新 MongoDB 集合。

核心 GA

az cosmosdb mongodb collection create

在 Azure Cosmos DB MongoDB 数据库下创建 MongoDB 集合。

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

示例

创建 Azure Cosmos DB MongoDB 集合。

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

必需参数

--account-name -a

Cosmosdb 帐户名称。

--database-name -d

数据库名称。

--name -n

集合名称。

--resource-group -g

资源组的名称。 可以使用 az configure --defaults group=<name> 配置默认组。

可选参数

--analytical-storage-ttl

启用分析存储时的分析 TTL。

--idx

索引,可以将其输入为字符串或文件, 例如,--idx 或 --idx @indexes-file.json “[{”key“: {”keys“: [”_ts“]},”options“: {”expireAfterSeconds“: 1000}}, {”key“: {”keys“: [”user_id“, ”user_address“]}, ”options“: {”unique“: ”true“}}]”。

--max-throughput

最大吞吐量资源可以扩展到 (RU/秒)。 在启用资源自动缩放时提供。 最小值可以为 4000 (RU/秒)。

--shard

分片键路径。

--throughput

MongoDB 集合(RU/s)的吞吐量。 默认值为 400。 如果数据库具有共享吞吐量,则省略此参数,除非集合应具有专用吞吐量。

全局参数
--debug

提高日志记录详细程度以显示所有调试日志。

--help -h

显示此帮助消息并退出。

--only-show-errors

只显示错误,取消显示警告。

--output -o

输出格式。

接受的值: json, jsonc, none, table, tsv, yaml, yamlc
默认值: json
--query

JMESPath 查询字符串。 有关更多信息和示例,请参阅 http://jmespath.org/

--subscription

订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID 配置默认订阅。

--verbose

提高日志记录详细程度。 使用 --debug 获取完整的调试日志。

az cosmosdb mongodb collection delete

删除 Azure Cosmos DB MongoDB 数据库下的 MongoDB 集合。

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

必需参数

--account-name -a

Cosmosdb 帐户名称。

--database-name -d

数据库名称。

--name -n

集合名称。

--resource-group -g

资源组的名称。 可以使用 az configure --defaults group=<name> 配置默认组。

可选参数

--yes -y

不提示确认。

默认值: False
全局参数
--debug

提高日志记录详细程度以显示所有调试日志。

--help -h

显示此帮助消息并退出。

--only-show-errors

只显示错误,取消显示警告。

--output -o

输出格式。

接受的值: json, jsonc, none, table, tsv, yaml, yamlc
默认值: json
--query

JMESPath 查询字符串。 有关更多信息和示例,请参阅 http://jmespath.org/

--subscription

订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID 配置默认订阅。

--verbose

提高日志记录详细程度。 使用 --debug 获取完整的调试日志。

az cosmosdb mongodb collection exists

检查 Azure Cosmos DB MongoDB 集合是否存在。

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

必需参数

--account-name -a

Cosmosdb 帐户名称。

--database-name -d

数据库名称。

--name -n

集合名称。

--resource-group -g

资源组的名称。 可以使用 az configure --defaults group=<name> 配置默认组。

全局参数
--debug

提高日志记录详细程度以显示所有调试日志。

--help -h

显示此帮助消息并退出。

--only-show-errors

只显示错误,取消显示警告。

--output -o

输出格式。

接受的值: json, jsonc, none, table, tsv, yaml, yamlc
默认值: json
--query

JMESPath 查询字符串。 有关更多信息和示例,请参阅 http://jmespath.org/

--subscription

订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID 配置默认订阅。

--verbose

提高日志记录详细程度。 使用 --debug 获取完整的调试日志。

az cosmosdb mongodb collection list

列出 Azure Cosmos DB MongoDB 数据库下的 MongoDB 集合。

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

必需参数

--account-name -a

Cosmosdb 帐户名称。

--database-name -d

数据库名称。

--resource-group -g

资源组的名称。 可以使用 az configure --defaults group=<name> 配置默认组。

全局参数
--debug

提高日志记录详细程度以显示所有调试日志。

--help -h

显示此帮助消息并退出。

--only-show-errors

只显示错误,取消显示警告。

--output -o

输出格式。

接受的值: json, jsonc, none, table, tsv, yaml, yamlc
默认值: json
--query

JMESPath 查询字符串。 有关更多信息和示例,请参阅 http://jmespath.org/

--subscription

订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID 配置默认订阅。

--verbose

提高日志记录详细程度。 使用 --debug 获取完整的调试日志。

az cosmosdb mongodb collection merge

预览

此命令处于预览阶段,正在开发中。 参考和支持级别: https://aka.ms/CLI_refstatus

合并 mongodb 集合的分区。

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

示例

集合 my-mongodb-collection 的合并分区

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

必需参数

--account-name -a

CosmosDB 数据库帐户的名称。

--database-name -d

mongoDB 数据库的名称。

--name -n

mongoDB 集合的名称。

--resource-group -g

资源组的名称。 可以使用 az configure --defaults group=<name> 配置默认组。

全局参数
--debug

提高日志记录详细程度以显示所有调试日志。

--help -h

显示此帮助消息并退出。

--only-show-errors

只显示错误,取消显示警告。

--output -o

输出格式。

接受的值: json, jsonc, none, table, tsv, yaml, yamlc
默认值: json
--query

JMESPath 查询字符串。 有关更多信息和示例,请参阅 http://jmespath.org/

--subscription

订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID 配置默认订阅。

--verbose

提高日志记录详细程度。 使用 --debug 获取完整的调试日志。

az cosmosdb mongodb collection redistribute-partition-throughput

预览

此命令处于预览阶段,正在开发中。 参考和支持级别: https://aka.ms/CLI_refstatus

重新分发 mongodb 集合的分区吞吐量。

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

示例

在所有物理分区之间均匀分配 mongodb 集合的分区吞吐量

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

将 mongodb 集合的分区吞吐量从源分区重新分发到目标分区

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'

必需参数

--account-name -a

CosmosDB 数据库帐户的名称。

--database-name -d

CosmosDB 数据库名称的名称。

--name -n

CosmosDB 集合的名称。

--resource-group -g

资源组的名称。 可以使用 az configure --defaults group=<name> 配置默认组。

可选参数

--evenly-distribute

切换为在所有物理分区之间平均分配吞吐量。

接受的值: false, true
默认值: False
--source-partition-info

空格分隔的源物理分区 ID,例如:1 2。

默认值: []
--target-partition-info

有关所需目标物理分区吞吐量的信息,例如:“0=1200 1=1200”。

默认值: []
全局参数
--debug

提高日志记录详细程度以显示所有调试日志。

--help -h

显示此帮助消息并退出。

--only-show-errors

只显示错误,取消显示警告。

--output -o

输出格式。

接受的值: json, jsonc, none, table, tsv, yaml, yamlc
默认值: json
--query

JMESPath 查询字符串。 有关更多信息和示例,请参阅 http://jmespath.org/

--subscription

订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID 配置默认订阅。

--verbose

提高日志记录详细程度。 使用 --debug 获取完整的调试日志。

az cosmosdb mongodb collection restore

在同一帐户中还原已删除的 mongodb 集合。

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

示例

在同一帐户中还原已删除的 mongodb 集合。

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

必需参数

--account-name -a

Cosmosdb 帐户名称。

--database-name -d

数据库名称。

--name -n

集合名称。

--resource-group -g

资源组的名称。 可以使用 az configure --defaults group=<name> 配置默认组。

可选参数

--restore-timestamp -t

集合需要还原到的时间戳。

全局参数
--debug

提高日志记录详细程度以显示所有调试日志。

--help -h

显示此帮助消息并退出。

--only-show-errors

只显示错误,取消显示警告。

--output -o

输出格式。

接受的值: json, jsonc, none, table, tsv, yaml, yamlc
默认值: json
--query

JMESPath 查询字符串。 有关更多信息和示例,请参阅 http://jmespath.org/

--subscription

订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID 配置默认订阅。

--verbose

提高日志记录详细程度。 使用 --debug 获取完整的调试日志。

az cosmosdb mongodb collection restore (cosmosdb-preview 扩展)

预览

此命令处于预览阶段,正在开发中。 参考和支持级别: https://aka.ms/CLI_refstatus

在同一帐户中还原已删除的 mongodb 集合。

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

示例

在同一帐户中还原已删除的 mongodb 集合。

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

必需参数

--account-name -a

Cosmosdb 帐户名称。

--database-name -d

数据库名称。

--name -n

集合名称。

--resource-group -g

资源组的名称。 可以使用 az configure --defaults group=<name> 配置默认组。

可选参数

--disable-ttl
预览

禁用或禁用 ttl 还原。

接受的值: false, true
--restore-timestamp -t

集合需要还原到的时间戳。

全局参数
--debug

提高日志记录详细程度以显示所有调试日志。

--help -h

显示此帮助消息并退出。

--only-show-errors

只显示错误,取消显示警告。

--output -o

输出格式。

接受的值: json, jsonc, none, table, tsv, yaml, yamlc
默认值: json
--query

JMESPath 查询字符串。 有关更多信息和示例,请参阅 http://jmespath.org/

--subscription

订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID 配置默认订阅。

--verbose

提高日志记录详细程度。 使用 --debug 获取完整的调试日志。

az cosmosdb mongodb collection retrieve-partition-throughput

预览

此命令处于预览阶段,正在开发中。 参考和支持级别: https://aka.ms/CLI_refstatus

检索 mongodb 集合的分区吞吐量。

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

示例

检索特定物理分区的容器container_name吞吐量

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

检索所有物理分区的容器container_name吞吐量

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

必需参数

--account-name -a

CosmosDB 数据库帐户的名称。

--database-name -d

CosmosDB 数据库名称的名称。

--name -n

CosmosDB 容器的名称。

--resource-group -g

资源组的名称。 可以使用 az configure --defaults group=<name> 配置默认组。

可选参数

--all-partitions

切换到检索所有物理分区的吞吐量。

接受的值: false, true
默认值: False
--physical-partition-ids -p

物理分区 ID 的空间分隔列表。

默认值: []
全局参数
--debug

提高日志记录详细程度以显示所有调试日志。

--help -h

显示此帮助消息并退出。

--only-show-errors

只显示错误,取消显示警告。

--output -o

输出格式。

接受的值: json, jsonc, none, table, tsv, yaml, yamlc
默认值: json
--query

JMESPath 查询字符串。 有关更多信息和示例,请参阅 http://jmespath.org/

--subscription

订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID 配置默认订阅。

--verbose

提高日志记录详细程度。 使用 --debug 获取完整的调试日志。

az cosmosdb mongodb collection show

显示 Azure Cosmos DB MongoDB 数据库下 MongoDB 集合的详细信息。

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

必需参数

--account-name -a

Cosmosdb 帐户名称。

--database-name -d

数据库名称。

--name -n

集合名称。

--resource-group -g

资源组的名称。 可以使用 az configure --defaults group=<name> 配置默认组。

全局参数
--debug

提高日志记录详细程度以显示所有调试日志。

--help -h

显示此帮助消息并退出。

--only-show-errors

只显示错误,取消显示警告。

--output -o

输出格式。

接受的值: json, jsonc, none, table, tsv, yaml, yamlc
默认值: json
--query

JMESPath 查询字符串。 有关更多信息和示例,请参阅 http://jmespath.org/

--subscription

订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID 配置默认订阅。

--verbose

提高日志记录详细程度。 使用 --debug 获取完整的调试日志。

az cosmosdb mongodb collection update

在 Azure Cosmos DB MongoDB 数据库下更新 MongoDB 集合。

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

必需参数

--account-name -a

Cosmosdb 帐户名称。

--database-name -d

数据库名称。

--name -n

集合名称。

--resource-group -g

资源组的名称。 可以使用 az configure --defaults group=<name> 配置默认组。

可选参数

--analytical-storage-ttl

启用分析存储时的分析 TTL。

--idx

索引,可以将其输入为字符串或文件, 例如,--idx 或 --idx @indexes-file.json “[{”key“: {”keys“: [”_ts“]},”options“: {”expireAfterSeconds“: 1000}}, {”key“: {”keys“: [”user_id“, ”user_address“]}, ”options“: {”unique“: ”true“}}]”。

全局参数
--debug

提高日志记录详细程度以显示所有调试日志。

--help -h

显示此帮助消息并退出。

--only-show-errors

只显示错误,取消显示警告。

--output -o

输出格式。

接受的值: json, jsonc, none, table, tsv, yaml, yamlc
默认值: json
--query

JMESPath 查询字符串。 有关更多信息和示例,请参阅 http://jmespath.org/

--subscription

订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID 配置默认订阅。

--verbose

提高日志记录详细程度。 使用 --debug 获取完整的调试日志。