避免在Azure EventGrid中将DateTimeOffset转换为UTC时间 [英] Avoid Converting DateTimeOffset to UTC time in Azure EventGrid
问题描述
我一直在测试Azure的EventGrid和一个我想做的事情之一是发送一个事件,其中PayLoad的一部分是DateTimeOffset字段.我是 使用标准EventGridClient发布事件:
使用(变量客户端=新的EventGridClient(topicCredentials)) { 等待客户端.PublishEventsAsync(topicHostname,eventGridEvents).ConfigureAwait(false); }
解决方案
AFAIK没有这样的配置可保留 DateTimeOffset .要解决此问题,您可以将偏移量存储在某个字段中,然后使用该偏移量将其转换回接收端.
I've been testing out Azure's EventGrid and one of the things I'm trying to do is send an event where part of the PayLoad is a DateTimeOffset field. I'm publishing the event using the standard EventGridClient:
using (var client = new EventGridClient(topicCredentials)) { await client.PublishEventsAsync(topicHostname, eventGridEvents).ConfigureAwait(false); }
I've fired up Fiddler and verified that the date portion is getting serialized as I would expect: "CheckInDate": "2018-12-26T14:47:42.8-08:00"
But when my subscribed Azure Functions listener receives the HttpTrigger and reads the message's content, the same item has somehow been formatted as UTC: "CheckInDate": "2018-12-26T22:47:42.8+00:00".
Is there a setting or something I need to enable to get it to preserve the original offset?
AFAIK there is no such configuration available to preserve DateTimeOffset. To Workaround this, you can store the offset in a some field and convert it back on the receiving side using that offset.
这篇关于避免在Azure EventGrid中将DateTimeOffset转换为UTC时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!