Search code examples
azure-webjobsazure-webjobssdkazure-eventgrid

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)

Solution

  • 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