Azure Cosmos DB 要求提供存储过程的分区键

标签 azure azure-cosmosdb

我使用 GUID Id 作为分区键,当我尝试运行存储过程时遇到问题。要运行存储过程,我需要提供分区键,但我不确定在这种情况下应该提供什么值?请帮忙。

最佳答案

If the collection the stored procedure is registered against is a single-partition collection, then the transaction is scoped to all the documents within the collection. If the collection is partitioned, then stored procedures are executed in the transaction scope of a single partition key. Each stored procedure execution must then include a partition key value corresponding to the scope the transaction must run under.

您可以引用上面的描述,提到here

正如 @Rafat Sarosh 所说,GUID Id 不是合适的分区键。根据您的情况,city 可能更合适。您可能需要调整数据库分区方案,因为分区键定义后无法删除或修改。

我建议你exporting your datajson 文件,然后 import通过 Azure Cosmos DB Data migration tool 到按 city 分区的新集合.

希望对您有帮助。

<小时/>

仅供总结:

问题:

执行sql查询文档时无法提供特定的分区键值。

解决方案:

1.执行查询sql时将EnableCrossPartitionQuery设置为true。(有性能瓶颈)

2.考虑将经常查询的字段设置为分区键。

关于Azure Cosmos DB 要求提供存储过程的分区键,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48798523/

相关文章:

entity-framework - 由于 nvarchar(max) 字段,插入语句超时

macos - 在 mac os 上运行 azure 时 Node.js 异常 201

Azure B2C 自定义流程

azure-cosmosdb - 如何获取 DocumentDB 文档中所有集合的列表?

c# - 从 Azure 下载文件

azure - 使用 Azure Cosmos 和 Blob 存储的分布式事务

azure - 是否可以禁用 Azure CosmosDB 存储过程的 5 秒时间限制

c# - 如何在 C# 代码中连接到 azure cosmos db 帐户而不使用主键

azure - 尝试将 Azure Function 绑定(bind)到 CosmosDB 时出错

.net - 在 azure 上无法找到程序集 'Microsoft.IdentityModel"错误