简体   繁体   English

当我使用 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"

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.

相关问题 参数类型“用户?” 不能分配给参数类型“未来<object?> ?'.,我什么时候可以让代码得到这个错误</object?> - The argument type 'User?' can't be assigned to the parameter type 'Future<Object?>?'., when i can the code got this error 使用 Pulumi Cli 导入 aws.alb.TargetGroup 时如何解决此错误 - How I can solve this error when importing aws.alb.TargetGroup using Pulumi Cli 找不到资源 Azure Cosmos DB - Resource Not Found Azure Cosmos DB 如何使用 Bot Framework Composer V2 传输 Azure Cosmos DB 中变量的字符串值? - how can I transfer the string value of a variable in Azure Cosmos DB using the Bot Framework Composer V2? 使用 cosmosdb SQLAPI,我能够创建我指定的 partitionKey 和 ID,但没有其他内容 - Using the cosmosdb SQLAPI, I'm able to create the partitionKey and ID I'm specifying, but no other content 我如何设置 RBAC gremlin cosmos db DefaultAzureCredentials - How do i setup RBAC gremlin cosmos db DefaultAzureCredentials “TypeError: _internal_init() got multiple values for argument”创建时出错 Azure App Insights with Pulumi - " TypeError: _internal_init() got multiple values for argument" error when created Azure App Insights with Pulumi 我收到此错误“_TypeError(类型‘_InternalLinkedHashMap<string, dynamic> ' 不是类型 'Iterable 的子类型<dynamic> ')" 从 api 数组调用</dynamic></string,> - I get this error "_TypeError (type '_InternalLinkedHashMap<String, dynamic>' is not a subtype of type 'Iterable<dynamic>')" from api array call 在 Cosmos DB 中查询嵌套数组 - Query Nested Array in Cosmos DB 使用 with 子句时出错我收到消息“语法错误:预期的关键字 AS 但在 [7:14] 得到了“(” - Error using the with clause I received message " Syntax error: Expected keyword AS but got "(" at [7:14]"
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM