azure - 与 SendGrid 一起用作输出绑定(bind)时 Azure 函数中的错误处理

标签 azure azure-functions sendgrid

我有一个 C# Azure 函数,其输出绑定(bind)到 SendGrid。 当消息到达 ServiceBus 主题时,会触发此 Azure 函数。我对消息进行操作,最后返回SendGridMessage。这里,SendGrid 负责发送实际的电子邮件。

但在整个场景中,Azure 函数无法知道电子邮件是否已送达或失败。有什么方法或钩子(Hook)可以给我上述详细信息吗?

任何链接、示例都值得赞赏。

谢谢

最佳答案

我认为没有办法使用 Sendgrid 绑定(bind),因为所有发送逻辑都被抽象掉了。但是,如果您需要的话,在您的函数中实例化您自己的 Sendgrid 客户端并不复杂:

using SendGrid;
using SendGrid.Helpers.Mail;

static SendGridClient _sendGridClient = new SendGridClient(ConfigurationManager.AppSettings["SendgridApiKey"]);

var msg = MailHelper.CreateSingleEmail(from, to, subject, plainTextContent, htmlContent);
var result = await _sendGridClient.SendEmailAsync(msg);
log.LogDebug($"SendGrid result={result.Body}");

关于azure - 与 SendGrid 一起用作输出绑定(bind)时 Azure 函数中的错误处理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55861426/

相关文章:

具有逻辑应用程序重复触发器的Azure函数

php - 如何实现一个可以轻松与SendGrid集成的邮件队列

centos - 使用 SendGrid/Gmail 时 SMTP 身份验证失败

azure - 无法从 SSMS 连接到 Azure Sql 数据库 : "The public data endpoint on this server is not accessible..."

c# - Azure,ClosedXML : Build will NOT include DocumentFormat. OpenXML 在我的应用程序的 bin 文件夹中

azure - 如何将 Azure 应用服务域用于静态 Web 应用?

azure - 从 Azure Function 进行身份验证并调用 Sharepoint Online Api

node.js - 如何包含用于azure nodejs功能的azure sdk?

c# - 函数 'IotHubTrigger' 的监听器无法启动。物联网中心

c# - 禁止状态 - 使用 Sendgrid 发送电子邮件时