How to use id and eventTime default values in custom event grid topic?

JR 0 Reputation points
2023-01-24T15:21:05.1066667+00:00

I am trying to understand how the highlighted statement works when creating custom event grid topic.

IdandEventTimeNotMapped

According to the description, a value will be generated if you do not put any mapping in id or eventTime. Presumably, it should be the default value assigned but when I publish the following json data, It does not generate any id or eventTime.

Test Data:
[{
	"subject":"TestSubject",
	"topic":"TestTopic",
	"eventType":"TestEventType",
	"dataVersion":"",
	"metadataVersion":"",
	"data":
		{"test":"test"}
}]

Publish Output:
[{
	\"subject\":\"TestSubject\",
	\"topic\":\"TestTopic\",
	\"eventType\":\"TestEventType\",
	\"dataVersion\":\"\",
	\"metadataVersion\":\"\",
	\"data\":
		{\"test\":\"test\"}
}]


Test Data with Id and eventTime:
[{
	"id":null,
	"subject":"TestSubject",
	"topic":"TestTopic",
	"eventType":"TestEventType",
	"eventTime":null,
	"dataVersion":"",
	"metadataVersion":"",
	"data":
		{"test":"test"}
}]

Publish Output 2:
[{\"id\":null,
\"subject\":\"TestSubject\",
\"topic\":\"TestTopic\",
\"eventType\":\"TestEventType\",
\"eventTime\":null,
\"dataVersion\":\"\",
\"metadataVersion\":\"\",
\"data\":{\"test\":\"test\"}}]
Azure Event Grid
Azure Event Grid
An Azure event routing service designed for high availability, consistent performance, and dynamic scale.
{count} votes

1 answer

Sort by: Most helpful
  1. Roman Kiss 2,246 Reputation points
    2023-01-25T07:34:48.9733333+00:00

    Hi,

    The custom input schema mapping allows to map the properties like is shown on the following screen snippet:

    customtopic

    Note, that the properties id and eventTime cannot have a default value explicitly like it is possible for other ones. In the case, when the value of that properties is null (included their mapped fields), the value will be generated by AEG.

    The following examples show a usage of the above custom input schema with EventGridSchema output:

    Input_1:

    [  
     {
        "data":{
          "make":"Ducati",
          "model":"Monster"
        }
      }
    ]
    

    Output_1:

    {
      "id":"3cd673e8-062a-4302-b0f6-85d0a61abe3b",
      "eventTime":"2023-01-25T07:19:55.2640365Z",
      "eventType":"myDefaultEventType",
      "dataVersion":"myDefaultDataVersion",
      "metadataVersion":"1",
      "topic":"############",
      "subject":"myDefaultSubject",
      "data":{
        "data":{
          "make":"Ducati",
          "model":"Monster"
        }
      }
    }
    

    Input_2:

    [
      {
        "myId":"1234567890",
        "data":{
          "make":"Ducati",
          "model":"Monster"
        }
      }
    ]
    

    Output_2:

    {
      "id":"1234567890",
      "eventTime":"2023-01-25T07:29:28.6468959Z",
      "eventType":"myDefaultEventType",
      "dataVersion":"myDefaultDataVersion",
      "metadataVersion":"1",
      "topic":"##################",
      "subject":"myDefaultSubject",
      "data":{
        "myId":"1234567890",
        "data":{
          "make":"Ducati",
          "model":"Monster"
        }
      }
    }
    

    Input_3:

    [
      {
        "myId":null,
        "data":{
          "make":"Ducati",
          "model":"Monster"
        }
      }
    ]
    

    Output_3:

    {
      "id":"a3592f1d-e4e9-4b21-b295-5efa33dacdc3",
      "eventTime":"2023-01-25T07:31:35.3012037Z",
      "eventType":"myDefaultEventType",
      "dataVersion":"myDefaultDataVersion",
      "metadataVersion":"1",
      "topic":"##################",
      "subject":"myDefaultSubject",
      "data":{
        "myId":null,
        "data":{
          "make":"Ducati",
          "model":"Monster"
        }
      }
    }
    

    Thanks

    Roman

    1 person found this answer helpful.

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.