Closed juvis closed 5 years ago
Check if you have a field or property named "Id", i had same issue, but after raname this field all works fine.
That did the trick! Thanks!
FYI I get the same json serialization error (as discussed above) when running the streamstone unit tests against CosmosDB Table storage... because the test EventData object/type has an Id property.
@colgreen I don't get it. What's so special about this field? It's just a custom column name. Are there any restrictions on column names in CosmosDB?
It's interesting that there is a deserialization exception when writing a record. My first thought is that the issue is in the Cosmos Table API code somewhere, i.e., it seems to have a problem deserializing the EventId type when writing a record. Honestly though, I was just playing with the different storage options, and thought you might be interested to know that the unit tests failed in this way when pointing to CosmosDB table storage. I used a connection string like so:
AccountName=Foo;TableEndpoint=https://localhost:8081/;AccountKey=<key here>
(That is pointing at an instance of the CosmosDB Emulator running on localhost)
Presumably a slightly different code path is used when using Azure Table Storage, that doesn't do that deserialization step(?)
Hi Will Streamstone support using Azure Cosmos DB with Azure Table Api anytime soon? I'm working on a proof of concept using Streamstone and was hoping that it was possible to use Streamstone with Cosmos DB since Streamstone now uses the Microsoft.Azure.Cosmos.Table api. I tried to run the example scenarios using a connection string to a Cosmos DB with Azure Table Api, but I get the error listed below:
Microsoft.Azure.Cosmos.Table.StorageException HResult=0x80131500 Message=Cannot deserialize the current JSON object (e.g. {"name":"value"}) into type 'System.String' because the type requires a JSON primitive value (e.g. string, number, boolean, null) to deserialize correctly. To fix this error either change the JSON to a JSON primitive value (e.g. string, number, boolean, null) or change the deserialized type so that it is a normal .NET type (e.g. not a primitive type like integer, not a collection type like an array or List) that can be deserialized from a JSON object. JsonObjectAttribute can also be added to the type to force it to deserialize from a JSON object.
Path 'Id.$t', line 1, position 45.
Source=Microsoft.Azure.Cosmos.Table
StackTrace:
at Microsoft.Azure.Cosmos.Table.Extensions.TableExtensionOperationHelper.d1`1.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.Azure.Cosmos.Table.Extensions.TableExtensionRetryPolicy.d 2d6.MoveNext() in C:\Development\Streamstone\Source\Streamstone\Stream.Operations.cs:line 96
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Streamstone.Stream.WriteOperation.Batch.Handle(StorageException exception) in C:\Development\Streamstone\Source\Streamstone\Stream.Operations.cs:line 241
at Streamstone.Stream.WriteOperation.d 6.MoveNext() in C:\Development\Streamstone\Source\Streamstone\Stream.Operations.cs:line 100
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at Example.Scenarios.S04_Write_to_stream.d1.MoveNext() in C:\Development\Streamstone\Source\Example\Scenarios\S04_Write_to_stream.cs:line 33
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Example.Scenarios.S04_Write_to_stream.d 0.MoveNext() in C:\Development\Streamstone\Source\Example\Scenarios\S04_Write_to_stream.cs:line 18
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Example.Program.d__0.MoveNext() in C:\Development\Streamstone\Source\Example\Program.cs:line 39
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Example.Program.(String[] args)
1.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.ConfiguredTaskAwaitable
1.ConfiguredTaskAwaiter.GetResult() at Streamstone.Stream.WriteOperation.Inner Exception 1: JsonSerializationException: Cannot deserialize the current JSON object (e.g. {"name":"value"}) into type 'System.String' because the type requires a JSON primitive value (e.g. string, number, boolean, null) to deserialize correctly. To fix this error either change the JSON to a JSON primitive value (e.g. string, number, boolean, null) or change the deserialized type so that it is a normal .NET type (e.g. not a primitive type like integer, not a collection type like an array or List) that can be deserialized from a JSON object. JsonObjectAttribute can also be added to the type to force it to deserialize from a JSON object.
Path 'Id.$t', line 1, position 45.