'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.
Regrading the above reference the Partition ID Input should be 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
Solution 1:[1]
Make the paths option an array:
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,
),
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | jaxxstorm |

