简体   繁体   English

Azure Stream Analytics输入会破坏包含时区信息的字符串

[英]Azure Stream Analytics input corrupts strings containing timezone info

I am using Azure Event Hub for collection of timebased events. 我使用Azure Event Hub收集基于时间的事件。 Connected Azure Stream Analytics (ASA) to it. 将Azure流分析(ASA)连接到它。

This results in losing the timezone info at ASA level. 这导致失去ASA级别的时区信息。

What I ascertained is the following: I have sent data in JSON format containing a string with a timestamp compatible with ISO 8601. eg: "event_timestamp": "2016-09-02T19:51:38.657+02:00" 我确定的内容如下:我已经发送了JSON格式的数据,其中包含一个时间戳与ISO 8601兼容的字符串。例如:“event_timestamp”:“2016-09-02T19:51:38.657 + 02:00”

I checked by means of ServiceBus Explorer (thanks to the guys who wrote this tool) that this string arrived exactly as-is in Event Hub. 我通过ServiceBus Explorer检查(感谢编写此工具的人),这个字符串完全按照事件中心的方式到达。

In the Stream Analytics I added the event hub as a input. 在Stream Analytics中,我添加了事件中心作为输入。 When I use the option SAMPLE DATA in the Azure portal this result in data containing: "event_timestamp":"2016-09-02T17:51:38.6570000" 当我在Azure门户中使用选项SAMPLE DATA时,会产生包含以下内容的数据:“event_timestamp”:“2016-09-02T17:51:38.6570000”

Why is Stream Analytics removing timezone info??? 为什么Stream Analytics删除时区信息???

According to ISO 8601 not specifying a timezone in a timestamp means that de timestamp is converted to localtime. 根据ISO 8601,未在时间戳中指定时区意味着将时间戳转换为本地时间。 Does that mean the timezone where the Azure resource is running? 这是否意味着Azure资源正在运行的时区? How can I use geo-replication in that case? 在这种情况下如何使用地理复制?

This means that after consuming the data and presenting it in a dashboard all times are related to the time of the server where the stream analytic runs? 这意味着在使用数据并将其显示在仪表板中后,所有时间都与流分析运行的服务器的时间相关?

Do I need to add the timezone information seperately in the JSON payload and reconstruct it afterwards? 我是否需要在JSON有效负载中单独添加时区信息并在之后重建它?

My conclusion is that actually ASA removes/destruct information from my data stream. 我的结论是,ASA实际上从我的数据流中删除/破坏了信息。 Imagine this ASA query: SELECT * INTO [myoutput] FROM [myinput] 想象一下这个ASA查询:SELECT * INTO [myoutput] FROM [myinput]

This would change the content (*) of my data. 这将改变我的数据的内容(*)。 All strings that appear to be a datetime with timezone info will be converted. 所有显示为带有时区信息的日期时间的字符串都将被转换。

In my opinion this is very unwanted behaviour. 在我看来,这是非常不受欢迎的行为。

I am very interested in the opinions of others in this forum. 我对这个论坛中其他人的意见很感兴趣。

Everything in Azure runs in UTC Timezone, unless otherwise supported and explicitly configured (there are not many services which support setting timezone). Azure中的所有内容都以UTC时区运行,除非另有支持和明确配置(没有很多服务支持设置时区)。

If you look at your quoted samples closely you will notice that the timestamp is converted to UTC in the ASA, that's why the TimeZone info is missing: 如果仔细查看引用的样本,您会注意到时间戳在ASA中转换为UTC,这就是TimeZone信息丢失的原因:

Sent to event hub: "event_timestamp": "2016-09-02T19:51:38.657+02:00" 发送到事件中心: "event_timestamp": "2016-09-02T19:51:38.657+02:00"

Received in ASA: "event_timestamp":"2016-09-02T21:51:38.6570000" 收到ASA: "event_timestamp":"2016-09-02T21:51:38.6570000"

Note that your event is sent in 19:51:38.657 +2:00 and ASA reads 21:51:38.6570000 which is absolutely the same. 请注意,您的活动发送时间为19:51:38.657 +2:00 ,ASA读取21:51:38.6570000 ,这是完全相同的。

UPDATE UPDATE

I am not expert on ISO standard, but here are some exerpts from ASA Docu: Azure Stream Analytics data types 我不是ISO标准的专家,但是这里有一些来自ASA Docu: Azure Stream Analytics数据类型的 exerpts

datetime Defines a date that is combined with a time of day with fractional seconds that is based on a 24-hour clock and relative to UTC (time zone offset 0). datetime定义一个日期,该日期与基于24小时制且相对于UTC(时区偏移0)的小数秒的时间相结合。

convertions: convertions:

datetime string converted to datetime following ISO 8601 standard 日期时间字符串按照ISO 8601标准转换为日期时间

It is documented that date time is in UTC. 记录日期时间以UTC为单位。 Hence no need to explicitly specify it. 因此无需明确指定它。 Whether this comforts with the ISO I cannot tell, first because WikiPedia is not ISO Document, second because I am not ISO expert. 这是否适合ISO我无法分辨,首先是因为WikiPedia不是ISO Document,第二是因为我不是ISO专家。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM