gpt4 book ai didi

AzureFunctions 绑定(bind)到 SendGrid

转载 作者:行者123 更新时间:2023-12-05 09:19:13 25 4
gpt4 key购买 nike

尝试弄清楚如何从 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 key 进行了硬编码。这是我的 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": "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="bfd2daffd8d2ded6d391dcd0d2" rel="noreferrer noopener nofollow">[email protected]</a>",
"from": "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="b8d5ddf8dfd5d9d1d496d6d7" rel="noreferrer noopener nofollow">[email protected]</a>",
"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

我已授予 Apkey 在 SendGrid 中的完全访问权限。我错过了什么想法吗?

拉尔西

最佳答案

ApiKey 字段不是实际的 ApiKey,它应该是“功能应用程序设置”中定义的 AppSettings 键的名称。

关于AzureFunctions 绑定(bind)到 SendGrid,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41521465/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com