【发布时间】:2018-05-03 20:00:45
【问题描述】:
az cosmosdb collection create 的 Microsoft 文档
表示--partition-key-path 可用于命名用于集合的键。在这种情况下,它是一个“MongoDB”集合:
name='myName'
databaseName='myDatabase'
resourceGroupName='myRg'
collectionName='myCollection'
echo "Create database account"
az cosmosdb create --name $name --kind MongoDB --locations "Central US"=0 --resource-group $resourceGroupName
echo "Create database"
az cosmosdb database create --name $name --db-name $databaseName --resource-group $resourceGroupName
echo "Create collection $collectionName"
az cosmosdb collection create --name $name --db-name $databaseName --resource-group $resourceGroupName --collection-name $collectionName --partition-key-path '/partition'
我需要更改哪些内容以避免出现以下错误并创建分区集合?
Create database account
...
Create database
...
Create collection myCollection
ERROR: Operation Failed: Invalid Arg {"Errors":["The partition key component definition path
'C:\/Apps\/Git\/partition' could not be accepted, failed near position '0'. Partition key paths must contain only
valid characters and not contain a trailing slash or wildcard character."]}
【问题讨论】:
-
只是为了确保我们在同一页面上。您正在创建一个数据库帐户,然后是一个集合。之前你也是在建数据库吗?
-
@NickChapsas - 是的,对不起。我会更新问题。
-
该错误基本上是对powershell的误解,认为您指向磁盘路径。这就是您在错误中得到
C:\/Apps\/Git\/partition的原因。您是否尝试将单引号替换为路径的双引号?这只是一个猜测。基本上任何能让系统明白这不是文件夹路径的东西都会起作用 -
@NickChapsas- 我试过双引号,也试过不带引号。我现在正在删除并重新创建所有内容,但我很快会重试。
-
这太奇怪了。无论如何,我很高兴它正在工作。