pzaj
pzaj

Reputation: 1092

EventGrid trigger / handler in WebJobs

Straight to the point: is there a way to handle EventGrid events in WebJobs?

What I've got so far is:

var builder = new HostBuilder()
                        .UseEnvironment(Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT"))
                        .ConfigureWebJobs(config =>
                        {
                            config.AddEventGrid();
                            config.AddAzureStorageCoreServices();
                            // config.AddTimers();
                        })

Which registers the EventGrid extension, I also have a handler (class with a method using EventGridTrigger attribute).

When I run it I can see in logs that the extension is initialised: enter image description here

And the host seems to be aware of the function as well: enter image description here

This is my function / handler so far (not very helpful presumably):

public class EventGridHandler
    {
        public Task Run([EventGridTrigger] CloudEvent ev)
        {
            return Task.CompletedTask;
        }
    }

Few questions that are rather obvious:

  1. How to configure the endpoint?
  2. Is there anything else I will need to make it work? (assuming that it's possible to make it work)

Upvotes: 0

Views: 343

Answers (2)

Jan Izaak Oosthoek
Jan Izaak Oosthoek

Reputation: 41

I got stuck on the same problem. My solution was simple:

  • create an storage account queue
  • subscribe the gridevent to deliver into the queue
  • use QueueTrigger in WebJob

Hopefully they allow us soon to set a configuration for the receiving part without an additional stop in a queue.

Upvotes: 1

pzaj
pzaj

Reputation: 1092

Short answer: It's not possible

Longer answer: In order to expose EventGrid extension one needs an implementation for IWebhookProvider and the only implementation I could find lives in Azure Functions Host

Upvotes: 0

Related Questions