Writing to AzureTableStorage fail when using NodaTime
etbuilder opened this issue · 2 comments
etbuilder commented
When using Nodatime in my .net core project, the following is added to guarantee serialization of Nodatime
services.AddMvc()
.AddJsonOptions(options =>
{
options.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
options.SerializerSettings.ConfigureForNodaTime(DateTimeZoneProviders.Tzdb); // noda serialization // this will diable automatic handeling of datetime
});
var serializer = new JsonSerializerSettings() {
ContractResolver = new CamelCasePropertyNamesContractResolver(),
};
serializer.ConfigureForNodaTime(DateTimeZoneProviders.Tzdb);
JsonConvert.DefaultSettings = () => serializer;
The problem arise when serializing the
Timestamp = log.Timestamp.ToUniversalTime().DateTime
When removing the conversion, the logging to azure table works again
Timestamp = log.Timestamp.ToUniversalTime()
without converting to DateTime as the TimeStamp is of type DateTimeOffset
pwelter34 commented
No longer relevant. The sink has been rewritten in version 8. Please open a new issue if still having problems.