如何为Cosmos DB Change Feed处理器中的RegisterObserverFactoryAsync函数提供PartitionKey? [英] How do I supply PartitionKey for RegisterObserverFactoryAsync function in Cosmos DB Change Feed processor?
问题描述
我正在从路径https://github.com/Azure/azure-documentdb-dotnet/tree/master/samples/ChangeFeedMigrationTool 保持不变.我只更改了App.config文件中所需的键值以指向我的Cosmos DB.
I am running the Change Feed Processor sample from the path https://github.com/Azure/azure-documentdb-dotnet/tree/master/samples/ChangeFeedMigrationTool as is. I have only changed the required key values in the App.config file to point to my Cosmos DB.
当我对分区集合运行此样本时,在注册观察者工厂时出现异常.
When I run this sample against partitioned collection, I get exception while registering the observer factory.
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库隐式管理所有分区.
But the function does not accept any partition key. And I don't know how to pass one. Am I missing anything in this? Also, my understanding is Cosmos DB Change Feed Processor library manages all partitions implicitly.
推荐答案
租约集合是否已分区?当前不支持分区租赁集合(应该很快),并且错误消息将是这样的.您可以尝试使用单分区租赁集合吗?
Is lease collection partitioned? Partitioned lease collection is not currently supported (should be soon), and error message would be something like this. Can you try using single-partition lease collection.
这篇关于如何为Cosmos DB Change Feed处理器中的RegisterObserverFactoryAsync函数提供PartitionKey?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!