当我使用 Pulumi 在 Cosmos DB 中创建容器时,我收到此错误“'resource.partitionKey.paths' 应该是 'array' 类型但得到了一个字符串”

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"

我尝试使用来自此 reference 的 Pulumi 在我的 Cosmos Db 上创建一些容器。

对以上参考进行重新分级,分区 ID 输入应为 String

我的代码是:

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,
                                                                        ),
                                                                        )

但我收到以下错误:

 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

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,
                                                                        ),