[英]When I create containers in Cosmos DB with the Pulumi I received this error "'resource.partitionKey.paths' should be of type 'array' but got a string"
I tried to create some containers on my Cosmos Db with the Pulumi from this reference .我尝试使用此参考资料中的 Pulumi 在我的 Cosmos Db 上创建一些容器。
Regrading the above reference the Partition ID Input should be String
.根据以上参考,分区 ID 输入应为String
。
My code is:我的代码是:
from pulumi_azure_native import documentdb
containers_name = {
'mytest1': '/test1',
'mytest2': '/test2',
'mytest3': '/test3',
}
# Create Containers
for container in containers_name.keys():
sql_api_resource_container = documentdb.SqlResourceSqlContainer('sql_api_resource_container',
args=documentdb.SqlResourceSqlContainerArgs(
account_name=cosmos_db.name,
database_name=sql_api_resource_database.name,
resource=documentdb.SqlContainerResourceArgs(
id=container,
partition_key=documentdb.ContainerPartitionKeyArgs(
kind='HASH',
paths=containers_name[container],
),
),
resource_group_name=resource_group_name,
container_name=container,
location=location_name,
tags=tags_group,
),
)
But I received the below error:但我收到以下错误:
error: azure-native:documentdb:SqlResourceSqlContainer resource 'sql_api_resource_container' has a problem: 'resource.partitionKey.paths' should be of type 'array' but got a string
Make the paths
option an array:使paths
选项成为一个数组:
from pulumi_azure_native import documentdb
containers_name = {
'mytest1': '/test1',
'mytest2': '/test2',
'mytest3': '/test3',
}
# Create Containers
for container in containers_name.keys():
sql_api_resource_container = documentdb.SqlResourceSqlContainer('sql_api_resource_container',
args=documentdb.SqlResourceSqlContainerArgs(
account_name=cosmos_db.name,
database_name=sql_api_resource_database.name,
resource=documentdb.SqlContainerResourceArgs(
id=container,
partition_key=documentdb.ContainerPartitionKeyArgs(
kind='HASH',
paths=[containers_name[container]], # should be an array
),
),
resource_group_name=resource_group_name,
container_name=container,
location=location_name,
tags=tags_group,
),
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.