Skip to content

A library for .NET that converts Twilio SendGrid web hook events into EventGrid events and publishes them.

License

Notifications You must be signed in to change notification settings

gtmoose32/sendgrid-azure-eventgrid

Repository files navigation

Moosesoft.SendGrid.Azure.EventGrid

Build status nuget Nuget

What is it?

A library for .NET that converts Twilio SendGrid delivery and engagment events into Azure Event Grid events and publishes them to a topic.

Installing Moosesoft.SendGrid.Azure.EventGrid

dotnet add package Moosesoft.SendGrid.Azure.EventGrid

Azure Function Sample

Working version of the sample code below is found here. Note: The Azure Event Grid topic configuration settings in the sample are fakes.

public class SendGridEventHandler
{
    private readonly IEventGridEventPublisher _eventGridEventPublisher;

    public SendGridEventHandler(IEventGridEventPublisher eventGridEventPublisher)
    {
        _eventGridEventPublisher = eventGridEventPublisher ?? throw new ArgumentNullException(nameof(eventGridEventPublisher));
    }

    [FunctionName(nameof(HandleSendGridEventsAsync))]
    public async Task<IActionResult> HandleSendGridEventsAsync(
        [HttpTrigger(AuthorizationLevel.Function, "post", Route = null)] HttpRequest request, 
        CancellationToken cancellationToken)
    {
        await _eventGridEventPublisher.PublishEventsAsync(request.Body, cancellationToken).ConfigureAwait(false);

        return new OkResult();
    }
}

About

A library for .NET that converts Twilio SendGrid web hook events into EventGrid events and publishes them.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages