17. 例1: HTTP要求に対しHTMLページを返す
• webhook + API シナリオから作成
• 編集して保存後「関数の URL」にアクセスするとサイト
が見れる
using System.Net;
using System.Net.Http.Headers;
public static async Task<HttpResponseMessage> Run(HttpRequestMessage req, TraceWriter log)
{
var res = new HttpResponseMessage();
res.Content = new StringContent("<html><body>プロ生ちゃん</body></html>");
res.Content.Headers.ContentType = new MediaTypeHeaderValue("text/html");
return res;
}
23. 例2: GitHub 連携
• Issue のコメントが投稿されたら関数を実行
• この記事の内容をデモ
– https://docs.microsoft.com/ja-jp/azure/azure-
functions/functions-create-a-web-hook-or-api-function
• GitHub シークレットは「キー」を表示して「関数キー」の値を
使う
– ※ Azure 関数からのレスポンス Message が “The WebHook
signature provided by the ‘X-Hub-Signature’ header field
does not match the value expected by the
‘GitHubWebHookReceiver’ receiver. WebHook request is
invalid.” のとき