I am trying to use Azure Functions to send an email message through SendGrid. I have a function that has a storage queue trigger and an SendGrid output parameter. After adding a message in the queue the function runs but nothing else happens. When I login to Sendgrid it shows I have zero requests and delivered messages. Also I am not receiving any emails.
What could possibly be causing this? Is there any way to debug this further?
Here is my function code in C#:
public static class SendChatEmail {
[FunctionName ("SendChatEmail")]
public static void Run ([QueueTrigger ("decision-tree-emails", Connection = "AzureWebJobsStorage")] ChatData myQueueItem, [SendGrid (ApiKey = "SendGridApiKey")] out SendGridMessage message,
TraceWriter log) {
log.Info ($"C# Queue trigger function processed: {myQueueItem}");
message = new SendGridMessage ();
message.AddTo ("[email protected]");
message.AddContent ("text/html", "Hello there!");
message.SetFrom (new EmailAddress ("[email protected]"));
message.SetSubject ("Chat conversation");
}
}
I'm using:
Azure Functions Core Tools (220.0.0-beta.0)
Function Runtime Version: 2.0.11651.0
Microsoft Visual Studio Enterprise 2017 Version 15.7.1
Azure Functions and Web Jobs Tools - 15.0.40502.0
I've also tried to make a similar Function in Node.js without getting it to work any better. Maybe I'm using SendGrid somehow wrong?