2017-01-07 2 views
1

azure関数から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キーで、件名と本文、から、にハードコードしました。私はSendGridでAPIKEYフルアクセスを許可している

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 

:私は次のエラーを取得する

{ 
"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.jsonです。私が逃したアイデアは何ですか?

Larsi

答えて

4

APIKEYフィールドには、それは代わりに「機能アプリの設定」で定義されているのAppSettingsキーの名前である必要があり、実際のAPIKEYではありません。

+2

はい、これは人々を大きく動かします。私たちはセキュリティの目的で、ソースコードファイルから秘密の価値を引き出すためにこれを行います。これらのケースでエラーメッセージを改善するために私たちのレポに問題を記録しました:https://github.com/Azure/azure-webjobs-sdk/issues/965 – mathewc