【发布时间】:2018-10-28 12:00:06
【问题描述】:
我正在尝试使用 Azure Functions 通过 SendGrid 发送电子邮件。我有一个具有存储队列触发器和 SendGrid 输出参数的函数。在队列中添加消息后,该函数运行但没有其他任何反应。当我登录到 Sendgrid 时,它显示我的请求和传递的消息为零。我也没有收到任何电子邮件。
这可能是什么原因造成的?有什么办法可以进一步调试吗?
这是我在 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 ("matti.petrelius@gmail.com");
message.AddContent ("text/html", "Hello there!");
message.SetFrom (new EmailAddress ("matti.petrelius@gmail.com"));
message.SetSubject ("Chat conversation");
}
}
我正在使用:
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
我也尝试在 Node.js 中创建一个类似的函数,但没有让它更好地工作。也许我使用 SendGrid 有点错误?
【问题讨论】:
标签: azure azure-functions sendgrid