首页 > 解决方案 > Azure Functions SendGrid 输出绑定未在 SendGrid 中显示为消息

问题描述

我正在尝试使用 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 不知何故错了?

标签: azureazure-functionssendgrid

解决方案


好吧,不管这个!事实证明,SendGrid 中的仪表板更新速度非常慢,并且在几个小时后没有显示请求。所以请求被发送和交付,仪表板只是没有显示它。此外,我没有注意到收到电子邮件,因为它们直接被定向到垃圾邮件!所以这是一场虚惊。SendGrid 绑定按照我的方式工作得很好。


推荐阅读