首页 文章

如何在Cosmos DB Change Feed处理器中为RegisterObserverFactoryAsync函数提供PartitionKey?

提问于
浏览
0

我正在路径https://github.com/Azure/azure-documentdb-dotnet/tree/master/samples/ChangeFeedMigrationTool中运行Change Feed Processor示例 . 我只更改了App.config文件中所需的键值以指向我的Cosmos DB .

当我针对分区集合运行此示例时,我在注册观察者工厂时遇到异常 .

await host.RegisterObserverFactoryAsync(docObserverFactory);

例外细节:

InvalidOperationException: PartitionKey value must be supplied for this operation.

   at Microsoft.Azure.Documents.Client.DocumentClient.<AddPartitionKeyInformationAsync>d__34f.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
...
at ChangeFeedMigrationSample.Program.<RunChangeFeedHostAsync>d__18.MoveNext() in D:\temp\samples\code-samples\ChangeFeedProcessor\Program.cs:line 181
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
   at ChangeFeedMigrationSample.Program.<MainAsync>d__16.MoveNext() in D:\temp\samples\code-samples\ChangeFeedProcessor\Program.cs:line 92

但该函数不接受任何分区键 . 而且我不知道如何通过一个 . 我错过了什么吗?另外,我的理解是Cosmos DB Change Feed Processor库隐式管理所有分区 .

1 回答

  • 2

    租赁集合是否已分区?目前不支持分区租约集合(应该很快),并且错误消息将是这样的 . 您可以尝试使用单分区租约收集 .

相关问题