Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 将.NET Core 3.1迁移到.NET 5.0,AzureFunctions,无法转换输入参数';需求';输入';System.Net.Http.HttpRequestMessage'; 我正在从.NET核心3.1迁移到我的Azure函数项目的.NET 5。我有以下功能去宽容: 使用Microsoft.Azure.Functions.Worker; 使用Microsoft.Azure.Functions.Worker.Http; 使用Microsoft.Extensions.Logging; 使用制度; 使用System.Collections.Generic; 使用System.IO; 使用System.Linq; 使用System.Net.Http; [功能(“测试”)] 公共静态异步任务运行([HttpTrigger(AuthorizationLevel.Anonymous,“get”,“post”,Route=null)]HttpRequestMessage请求, 伊洛格日志, Microsoft.Azure.WebJobs.ExecutionContext(上下文) { ... }_C#_.net_Azure Functions_.net 5_.net Core 3.1 - Fatal编程技术网

C# 将.NET Core 3.1迁移到.NET 5.0,AzureFunctions,无法转换输入参数';需求';输入';System.Net.Http.HttpRequestMessage'; 我正在从.NET核心3.1迁移到我的Azure函数项目的.NET 5。我有以下功能去宽容: 使用Microsoft.Azure.Functions.Worker; 使用Microsoft.Azure.Functions.Worker.Http; 使用Microsoft.Extensions.Logging; 使用制度; 使用System.Collections.Generic; 使用System.IO; 使用System.Linq; 使用System.Net.Http; [功能(“测试”)] 公共静态异步任务运行([HttpTrigger(AuthorizationLevel.Anonymous,“get”,“post”,Route=null)]HttpRequestMessage请求, 伊洛格日志, Microsoft.Azure.WebJobs.ExecutionContext(上下文) { ... }

C# 将.NET Core 3.1迁移到.NET 5.0,AzureFunctions,无法转换输入参数';需求';输入';System.Net.Http.HttpRequestMessage'; 我正在从.NET核心3.1迁移到我的Azure函数项目的.NET 5。我有以下功能去宽容: 使用Microsoft.Azure.Functions.Worker; 使用Microsoft.Azure.Functions.Worker.Http; 使用Microsoft.Extensions.Logging; 使用制度; 使用System.Collections.Generic; 使用System.IO; 使用System.Linq; 使用System.Net.Http; [功能(“测试”)] 公共静态异步任务运行([HttpTrigger(AuthorizationLevel.Anonymous,“get”,“post”,Route=null)]HttpRequestMessage请求, 伊洛格日志, Microsoft.Azure.WebJobs.ExecutionContext(上下文) { ... },c#,.net,azure-functions,.net-5,.net-core-3.1,C#,.net,Azure Functions,.net 5,.net Core 3.1,但是,我收到以下错误消息: System.Private.CoreLib: Exception while executing function: Functions.SaveBlob. System.Private.CoreLib: Result: Failure Exception: Microsoft.Azure.Functions.Worker.Diagnostics.Exceptions.FunctionInputConverterException: Error converting

但是,我收到以下错误消息:

System.Private.CoreLib: Exception while executing function: Functions.SaveBlob. System.Private.CoreLib: Result: Failure
Exception: Microsoft.Azure.Functions.Worker.Diagnostics.Exceptions.FunctionInputConverterException: Error converting 1 input parameters for Function 'Test': Cannot convert input parameter 'req' to type 'System.Net.Http.HttpRequestMessage' from type 'Microsoft.Azure.Functions.Worker.GrpcHttpRequestData'.
我需要为我的应用程序保留ExecutionContext

如何修复此错误?

阅读后,我看到该类已重命名为

解决这个问题的方法很简单,将
ExecutionContext
重命名为
FunctionContext
。我意识到.NET 5 Azure功能不需要Microsoft.Azure.WebJobs。接下来,我需要将类型从
System.Net.Http.HttpRequestMessage
更改为
Microsoft.Azure.Functions.Worker.Http.HttpRequestData
。最后,我删除了
ILogger
,以支持

最后一个函数如下所示

使用系统;
使用System.IO;
使用System.Threading.Tasks;
使用Microsoft.Azure.Functions.Worker;
使用Microsoft.Azure.Functions.Worker.Http;
[功能(“测试”)]
公共静态HttpResponseData运行([HttpTrigger(AuthorizationLevel.Anonymous,“get”,“post”,Route=null)]HttpRequestData请求
函数(上下文)
{
...
}
升级时,请确保彻底升级。它还帮助通过VisualStudio代码创建一个新项目,使用.NET5查看新项目的结构