gpt4 book ai didi

c# - Azure函数: Cannot bind parameter '_return' to type HttpResponseMessage

转载 作者:可可西里 更新时间:2023-11-01 16:54:55 25 4
gpt4 key购买 nike

我从 quickstart guide 创建了基本的 Azure 函数。根据教程,这个默认功能应该立即起作用,但我收到错误。

函数体:

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.).

最佳答案

您现在可以通过将响应输出绑定(bind)的名称从 $return 更改为 res 来解决此问题。前者很快就会在我们的下一个版本中运行,但目前还没有。看来我们推出功能模板更新有点太早了 - 我创建了一个错误 here在我们针对该问题的存储库中。谢谢:)

关于c# - Azure函数: Cannot bind parameter '_return' to type HttpResponseMessage,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40590610/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com