You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过Azure CLI为Azure Cosmos DB (NoSQL)创建带分层分区键的容器?

使用Azure CLI创建带分层分区键的Azure Cosmos DB NoSQL容器

你可以通过Azure CLI的--partition-key-paths参数(替代单一的--partition-key-path)指定多个分层分区键路径,实现分层分区键的配置。若需要更精细的参数定义,也可通过JSON格式配置--partition-key参数。

方法1:直接指定多个分区键路径

用空格分隔多个分区键路径,示例命令如下:

az cosmosdb sql container create -g MyResourceGroup -a MyAccount -d MyDatabase -n MyContainer --partition-key-paths "/country" "/city" --throughput 400

方法2:通过JSON配置分区键

若需明确指定分区键类型(分层分区键对应MultiHash类型),可传入JSON字符串:

az cosmosdb sql container create -g MyResourceGroup -a MyAccount -d MyDatabase -n MyContainer --partition-key '{"paths": ["/country", "/city"], "kind": "MultiHash"}' --throughput 400

注意事项

  • 确保Azure CLI版本在2.40.0及以上,旧版本可能不支持分层分区键相关参数,可执行az upgrade升级CLI
  • 分层分区键最多支持3个路径
  • 容器创建完成后,分区键的结构(包括分层配置)无法修改

内容的提问来源于stack exchange,提问作者vmaroli

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.13 13:49:49