Lar*_*rsi 1 azure sendgrid azure-functions
试图弄清楚如何从 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();
}
Run Code Online (Sandbox Code Playgroud)
我已经对主题和正文以及集成输出部分中的 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
}
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
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
Run Code Online (Sandbox Code Playgroud)
我已在 SendGrid 中授予 Apikey 完全访问权限。任何想法我错过了什么?
拉西
ApiKey 字段不是实际的 ApiKey,它应该是“功能应用设置”中定义的 AppSettings 键的名称。
| 归档时间: |
|
| 查看次数: |
867 次 |
| 最近记录: |