【发布时间】:2017-01-07 12:31:27
【问题描述】:
试图弄清楚如何从一个 azure 函数中使用 SendGrid。找不到太多文档,但这是我尝试过的:
#r "SendGrid"
using SendGrid.Helpers.Mail;
using System;
public static void Run(string myQueueItem, out Mail message, TraceWriter log)
{
log.Info($"C# Queue trigger function processed: {myQueueItem}");
message=new Mail();
}
我已经硬编码到、从、主题和正文,以及集成输出部分中的 api 键。这是我的function.json:
{
"bindings": [
{
"name": "myQueueItem",
"type": "queueTrigger",
"direction": "in",
"queueName": "send-email-request",
"connection": "myStorage"
},
{
"type": "sendGrid",
"name": "message",
"apiKey": "SG.xxxxxxxxxxx",
"direction": "out",
"to": "me@gmail.com",
"from": "me@gmail.no",
"subject": "hardcoded",
"text": "test213"
}
],
"disabled": false
}
我收到以下错误:
Function ($SendEmailOnQueueTriggered) Error: Microsoft.Azure.WebJobs.Host: Error indexing method 'Functions.SendEmailOnQueueTriggered'. Microsoft.Azure.WebJobs.Host: 'SG.xxxxxx' does not resolve to a value.
Session Id: 9426f2d7e4374c7ba7e0612ea5dc1814
Timestamp: 2017-01-07T12:18:01.930Z
我已在 SendGrid 中授予 Apikey 完全访问权限。有什么我错过的想法吗?
拉西
【问题讨论】:
标签: azure sendgrid azure-functions