1
試圖找出如何使用從天藍色的函數SendGrid。沒有太多的文檔發現,但是這是我試過:AzureFunctions綁定到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": "[email protected]",
"from": "[email protected]",
"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完全訪問權限。任何想法,我已經錯過了?
Larsi
是的,這讓人們多了起來。我們這樣做是出於安全目的,將祕密值保留在源代碼文件之外。我在我們的回購中記錄了一個問題,以幫助我們改進這些情況下的錯誤消息:https://github.com/Azure/azure-webjobs-sdk/issues/965。 – mathewc