Defining Event Grid Publish Event Job Properties
Automic Automation Event Grid Publish Event Jobs allow you to publish events to your Event Grid application, making that information available for other applications or services. For example, you can notify Event Grid once an Automic Automation Job or Workflow has finished processing.
Azure Event Grid then delivers those events to subscriber destinations such as applications, Azure services, or any endpoint to which it has network access.
To publish an event to the Event Grid topic, you have to define the event object in JSON format. Depending on the event schema that you want to publish, the content of the JSON containing the attributes that you want to pass to the application varies. Those attributes then populate the corresponding fields in the target application.
You can decide how the JSON is created. For example, it could be created using a custom job or scripts in Automic Automation. Regardless of how the file is created, you have to make sure that it is available on the Agent machine (host).
This page includes the following:
Event Grid Publish Event Job
On the Publish Event Job page you define the parameters relevant to publish events to your Event Grid application.
-
Connection
Event Grid Connection object containing the relevant information to connect to the application.
To search for a Connection object, start typing its name to limit the list of the objects that match your input.
-
Event Schema
There are three event schemes available:
-
Event Grid: Allows you to publish Event Grid events.
-
Cloud: Allows you to publish cloud events.
-
Custom: Allows you to publish your own, customized events.
Each schema requires some mandatory parameter definition. For more information, see Event Schema Parameters.
-
-
Event Input Type
Select one of the options available:
-
JSON
Use the Event JSON field to enter the JSON payload definition.
Important!There are many options available to define the Event JSON. Make sure the definition not only matches the Event Schema that you have selected but also that includes the mandatory fields required for each schema. For more information and examples of the event JSON definition, see Defining the Event JSON for Event Grid Publish Event Jobs.
-
File Path
Use the Event JSON File Path field to define the path to the JSON file containing the attributes that you want to pass to the application. Make sure that you select the JSON file that corresponds to the event type that you have selected and that the file is available on the Agent machine (host).
-
The Pre-Process page allows you to define the settings of the Jobs using script statements. These statements are processed before the Publish Event Job is executed, see, Setting Event Grid Job Properties Through Scripts.
Defining the Event JSON for Event Grid Publish Event Jobs
This section gives you examples of how you could define the Event JSON field when defining a Publish Event Job. You have different options available; there are only two rules you need to follow:
-
Make sure that the payload matches the event schema that you have selected.
-
Make sure that the payload includes the mandatory fields required for each schema.
Event Schema Parameters
The fields available for each schema are the following:
-
Event Grid
These parameters are mandatory:
-
ID
It must be unique and can be generated automatically.
-
Subject
-
Event Type
-
Event Time
The event time must be defined in UTC format, for example, 2022-12-04T22:06:09.147165Z. It can be generated automatically.
Optionally, you can also define the following parameters:
-
Data
-
Data version
-
Metadata version
This value is set to 1 by default and cannot be changed.
-
-
Cloud
These parameters are mandatory:
-
ID
It must be unique and can be generated automatically.
-
Source
It must be unique and can be generated automatically.
-
Event Type
-
Event Time
The event time must be defined in UTC format, for example, 2022-12-04T22:06:09.147165Z. It can be generated automatically.
-
Spec Version
This value is set to 1 by default and cannot be changed.
Optionally, you can also define the following parameters:
-
Data
-
Data content type
-
Subject
-
Map <String, Object>
These are additional attributes.
-
-
Custom Custom events need to be tailored to the specific use case and have no mandatory parameters.
Simple JSON Definition
The first option to define the Event JSON is a simple payload definition.
Event Grid Event Example
[ { "id": "2222", "eventType": "recordInserted", "subject": "Test.EventGrid.Event", "eventTime": "2022-08-10T21:03:07+00:00", "data": { "make": "Test", "model": "Event Grid event" }, "dataVersion": "1.0" } ]
Cloud Event Example
[ { "id": 111111111111, "source": "/microsoft/autorest/examples/eventgrid/cloud-events/publish", "specversion": "1.0", "data": { "Property1": "Value1", "Property2": "Value2" }, "type": "Microsoft.EventGrid/topics", "time": "2022-12-04T22:06:09.147165Z" } ]
Custom Event Example
[ { "customid": "4567", "customeventtype": "recordInserted", "customMatter": "Test.Custom.Event", "customeventTime": "2022-08-10T21:03:07+00:00", "data": { "make": "Test Event", "model": "model custom event" }, "customdataVersion": "1.0" } ]
Using Variables
You can also use variables in the payload definition.
Example
In the Event JSON field, enter the following:
&JSON_VARIABLES#
If the variable is not defined yet, you must define it now. You do it on the Variables page of the Publish Event Job definition:
(Click to expand)
When you execute the Job, the variables will be replaced with the value you have just defined. This is visible in the Agent log (PLOG), see Monitoring Azure Event Grid Jobs
(Click to expand)
Optionally, you can also generate a unique ID and the time for a specific job run and pass that information to the Event Grid topic along with the rest of the JSON payload. To do so, use the following variables:
-
${AUTOGEN_UUID} to generate unique Id.
-
${AUTOGEN_TIME} to generate current time in the predefined format
Example
[ { "id": "automic-${AUTOGEN_UUID}", "source": "/automic/cloud-events/publish", "specversion": "1.0", "data": { "Property1": "Value1", "Property2": "Value2" }, "type": "Microsoft.EventGrid/topics", "time": "${AUTOGEN_TIME}" } ]
The variables are replaced with the generated values before the event is published.
[ { "id": "automic-22233-3dsdfd-sdsdsd-sdsffss", "source": "/automic/cloud-events/publish", "specversion": "1.0", "data": { "Property1": "Value1", "Property2": "Value2" }, "type": "Microsoft.EventGrid/topics", "time": "2022-12-04T22:06:09.147165Z" } ]
If there are multiple events, a new ${AUTOGEN_UUID} is generated for each one.
Publish Event Job in a Workflow
You can also use the Event JSON field if you want to include a Publish Event Job in a Workflow and you want to use Automation Engine variables in it.
Example
You have a Run DAG Job running in Automic Automation and, once it is executed, you want to publish that information to Event Grid, including the Automic Automation Run ID and the Start time.
In the Workflow, a Script object (SCRI) with the variable definition relevant for the Run DAG Job Run Id and the Start time precedes your Publish Event Job:
(Click to expand)
In the Publish Event Job, the Event JSON definition includes those variables:
(Click to expand)
Note: The definition of the Automic-&$RUNID# variable used in the example is done in the Variables page of the Job definition, see Defining Common Job Properties.
When the Job is executed, the variables will be replaced with the value you have just defined. This is visible in the Agent log (PLOG), see Monitoring Azure Event Grid Jobs:
(Click to expand)
See also: