Sign up for a SparkPost account and visit our Developer Hub for even more content.
This project contains a .NET Core service that consumes and processes SparkPost webhooks.
- A shiny new SparkPost Account - [sign up](sparkpost sign up)
- .NET Core Runtime 2.0 (Download)
- Visual Studio Code or Visual Studio 2017
git clone https://github.com/SparkPost/azure-csharp-webhook-sample.git
cd SparkPostWebhooksSample
dotnet restore
dotnet ef database update
dotnet run
The service is now listening on port 5000. It expects to receive POST
requests to the webhook endpoint http://localhost:5000/api/webhook containing valid SparkPost webhook batches in JSON format.
You can use ngrok to connect your local service to your SparkPost account nand send a test batch:
- Start ngrok:
ngrok http 5000
. Ngrok will create a tunnel and give you a public URL for your service. - Create a new Webhook on your SparkPost Account that points to your ngrok tunnel URL.
- Use the webhook test facility in SparkPost to send a test batch to your service.
When you send email through your SparkPost account, your webhook service will periodically receive batches of real events.
Note: Remember to shut your service down, remove the tunnel and delete the webhook from your SparkPost account when you're finished.