AzureFunctions 绑定到 SendGrid
AzureFunctions binding to SendGrid
正在尝试了解如何通过 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 完全访问权限。有什么我错过的想法吗?
拉尔西
ApiKey 字段不是实际的 ApiKey,它应该是 "functions app settings".
中定义的 AppSettings 密钥的名称
通过 local.settings.json 在您的 AppSettings 中添加“AzureWebJobsSendGridApiKey”,并通过 Azure 门户在配置 -> 应用程序设置中添加“AzureWebJobsSendGridApiKey”。
正在尝试了解如何通过 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 完全访问权限。有什么我错过的想法吗?
拉尔西
ApiKey 字段不是实际的 ApiKey,它应该是 "functions app settings".
中定义的 AppSettings 密钥的名称通过 local.settings.json 在您的 AppSettings 中添加“AzureWebJobsSendGridApiKey”,并通过 Azure 门户在配置 -> 应用程序设置中添加“AzureWebJobsSendGridApiKey”。