裏でFunction Appが実行中のときにコンパイルして(コンパイルエラーになったりして)るときに実行中のものはどうなるのか、予想では別物なんで問題ないと思いますが一応。
検証用コード
using System.Net; public static async Task<HttpResponseMessage> Run(HttpRequestMessage req, TraceWriter log) { log.Info($"Start ----"); // parse query parameter string name = req.GetQueryNameValuePairs() .FirstOrDefault(q => string.Compare(q.Key, "name", true) == 0) .Value; await Task.Delay(TimeSpan.FromSeconds(20)); // Get request body dynamic data = await req.Content.ReadAsAsync<object>(); // Set name to query string or body data name = name ?? data?.name; log.Info($"End ----------"); return name == null ? req.CreateResponse(HttpStatusCode.BadRequest, "Please pass a name on the query string or in the request body") : req.CreateResponse(HttpStatusCode.OK, "Hello " + name); }
HttpTriggerなC#のテンプレートにStartとEndのログと間にTask.Delayで処理止めてるだけのシンプルなやつです。
※ログにFunction Startedとか出るので無駄な気もするけど一応
手順的にはこんな感じ
1. 上記コードを実行する(適当に呼び出す)
2. Task.Delayしてる間にコードを適当に弄ってSaveしてコンパイルエラーにする
3. 結果を見る
4. そのまま再度呼び出す
実行結果はこんな感じになりました
2016-07-19T03:34:42.334 Function started (Id=14c91f2c-2490-437c-b461-258a13872d82) 2016-07-19T03:34:42.334 Start ---- 2016-07-19T03:34:45.698 Script for function 'HttpTriggerCSharp1' changed. Reloading. 2016-07-19T03:34:45.698 Compiling function script. 2016-07-19T03:34:45.776 run.csx(14,13): error CS1002: ; expected 2016-07-19T03:34:45.776 run.csx(11,48): error CS0246: The type or namespace name 'aaaa' could not be found (are you missing a using directive or an assembly reference?) 2016-07-19T03:34:45.776 run.csx(14,13): error CS0103: The name 'data' does not exist in the current context 2016-07-19T03:34:45.776 run.csx(17,20): error CS0103: The name 'data' does not exist in the current context 2016-07-19T03:34:45.776 run.csx(14,5): warning CS0168: The variable 'dynamic' is declared but never used 2016-07-19T03:34:45.776 Compilation failed. 2016-07-19T03:35:02.334 End ---------- 2016-07-19T03:35:02.334 Function completed (Success, Id=14c91f2c-2490-437c-b461-258a13872d82) 2016-07-19T03:35:27.915 Function compilation error 2016-07-19T03:35:27.915 run.csx(14,13): error CS1002: ; expected 2016-07-19T03:35:27.915 run.csx(11,48): error CS0246: The type or namespace name 'aaaa' could not be found (are you missing a using directive or an assembly reference?) 2016-07-19T03:35:27.915 run.csx(14,13): error CS0103: The name 'data' does not exist in the current context 2016-07-19T03:35:27.915 run.csx(17,20): error CS0103: The name 'data' does not exist in the current context 2016-07-19T03:35:27.915 run.csx(14,5): warning CS0168: The variable 'dynamic' is declared but never used 2016-07-19T03:35:27.915 Function completed (Failure) 2016-07-19T03:35:27.961 Exception while executing function: Functions.HttpTriggerCSharp1. Microsoft.Azure.WebJobs.Script: Script compilation failed.
StartとEndの間でコンパイル走ってエラーになってますが、Function Id=14c91f2c-2490-437c-b461-258a13872d82は継続して処理が完了してます。
その後再度呼び出してみるとコンパイルが完了してないので再度コンパイル→失敗→500エラーが返る、という感じです。
予想通りでしたね。なんかおかしい、という場合はぜひ追加の検証をお願いします。