Easiest way to send events to EventGrid Topic

There are several ways to send event to EventGridTopic.For example, you can use Azure CLI, PowerShell or write your own code. My favorite one is .NET Core Global Tool called eventgridpublisher. It is published as NUGET package.

You can install it as any regular .NET Core Global Tool from nuget repository.

dotnet tool install -g eventgridpublisher

After installation go to azure portal and lookup the key1:

As next grab the endpoint URL:

To start a toll open command prompt type eventgridpublisher. It will show you following:

Event Grid Publisher version 1.0.2
Application requires 5 arguments: key, topicHostName, eventFileFolder eventFileFilter, eventType.

Example: eventgridpublisher '***' 'https://***.westeurope-1.eventgrid.azure.net/api/events' sampleevents event1.json 'eventgrid/training/event1'

Example: eventgridpublisher '***' 'https://***.westeurope-1.eventgrid.azure.net/api/events' sampleevents *.json 'eventgrid/training/event1'

to specify events, which you want to send, you don't have to render them in the command line. YOU can rather create events in a text file like following one:

{
  "prop1": "event1",
  "prop2": 41
}

You can provide any content in a file. As long it is a text it will be sent to the topic.

Here is an example, which demonstrates how to send a specific file from the current folder:

eventgridpublisher '***' 'https://***.westeurope-1.eventgrid.azure.net/api/events' . 'telemetryEvent.json' 'eventType'

If you want to send multiple events as a batch, you can use wildcards:

eventgridpublisher '***' 'https://***.westeurope-1.eventgrid.azure.net/api/events' 'c"\myfolder\myevents' '*.json' 'eventType'