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. But my favorite is .NET Core Global Tool called eventgridpublisher. It is published as NUGET package.

You can install it as any regular .NET Core Global Tool:

dotnet tool install -g eventgridpublisher

After installation go to azure portal and lookup the key1:
111019_eg1

As next grab the endpoint URL:
111019_eg2

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. Simple create events in a 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'

111511_e

If you want to send multiple events as a batch:
eventgridpublisher '***' 'https://***.westeurope-1.eventgrid.azure.net/api/events' 'c"\myfolder\myevents' '*.json' 'eventType'

111515_e2


comments powered by Disqus