I'm trying to test a function subscribed to an event grid.
I found the following code that creates a custom event:
string topicEndpoint = "https://<topic-name>.<region>-1.eventgrid.azure.net/api/events";
string topicKey = "<topic-key>";
string topicHostname = new Uri(topicEndpoint).Host;
TopicCredentials topicCredentials = new TopicCredentials(topicKey);
EventGridClient client = new EventGridClient(topicCredentials);
client.PublishEventsAsync(topicHostname, GetEventsList()).GetAwaiter().GetResult();
Console.Write("Published events to Event Grid.");
static IList<EventGridEvent> GetEventsList()
{
List<EventGridEvent> eventsList = new List<EventGridEvent>();
for (int i = 0; i < 1; i++)
{
eventsList.Add(new EventGridEvent()
{
Id = Guid.NewGuid().ToString(),
EventType = "Contoso.Items.ItemReceivedEvent",
Data = new ContosoItemReceivedEventData()
{
ItemUri = "ContosoSuperItemUri"
},
EventTime = DateTime.Now,
Subject = "Door1",
DataVersion = "2.0"
});
}
return eventsList;
}
Now, how can I check if the function was actually triggered and if it is sending the sending response with C# code?
Also, in the above code, is the EventType
the name of the function to be triggered? Or how does the Event Grid knows which function to run?