2016-11-14 56 views
0

我從quickstart guide創建了基本的Azure函數。按照教程,這個默認功能應該立即工作,但我得到一個錯誤。Azure函數:無法綁定參數'_return'來鍵入HttpResponseMessage

函數體:

using System.Net; 

public static async Task<HttpResponseMessage> Run(HttpRequestMessage req, TraceWriter log) 
{ 
    log.Info("C# HTTP trigger function processed a request."); 

    // parse query parameter 
    string name = req.GetQueryNameValuePairs() 
     .FirstOrDefault(q => string.Compare(q.Key, "name", true) == 0) 
     .Value; 

    // Get request body 
    dynamic data = await req.Content.ReadAsAsync<object>(); 

    // Set name to query string or body data 
    name = name ?? data?.name; 

    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); 
} 

錯誤消息:

Function ($HttpTriggerCSharp1) Error: Microsoft.Azure.WebJobs.Host: Error indexing method 'Functions.HttpTriggerCSharp1'. Microsoft.Azure.WebJobs.Host: Cannot bind parameter '_return' to type HttpResponseMessage&. Make sure the parameter Type is supported by the binding. If you're using binding extensions (e.g. ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (e.g. config.UseServiceBus(), config.UseTimers(), etc.).

回答

4

您可以通過更改響應輸出從$returnres結合名稱解決這個問題現在。前者將在我們的下一個版本中很快開始工作,但尚未完成。看起來我們推出了一個功能模板更新,對於這個問題有點過早 - 我在我們的回購問題中創建了一個bug here。謝謝:)

+0

工作就像一個魅力,謝謝! –