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

使用Azure CLI创建Cosmos DB SQL容器时分区键路径报错求助

问题原因和解决方法

你遇到的问题是Git Bash的路径解析特性导致的:当你在Git Bash里用单引号包裹/zip时,Git Bash会把开头的斜杠解析成Git安装目录的根路径(也就是错误信息里的C:/Program Files/Git/),所以Azure CLI实际收到的分区键路径变成了C:/Program Files/Git/zip,自然不符合Cosmos DB对分区键路径的要求。

解决办法有几个:

  • 把单引号换成双引号包裹分区键路径:
    az cosmosdb sql container create --account-name testaccjul1 --resource-group demo-app-test --database-name cosdbjul2 --name container1 --partition-key-path "/zip" --throughput 400
    
  • 对斜杠进行转义,避免Git Bash解析:
    az cosmosdb sql container create --account-name testaccjul1 --resource-group demo-app-test --database-name cosdbjul2 --name container1 --partition-key-path \/zip --throughput 400
    
  • 换用PowerShell或者CMD执行你的原始命令,这两个终端不会有Git Bash的路径解析问题,直接用原来的命令就能正常运行。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.24 21:03:31