Fra*_*rpa 3 c# azure visual-studio azure-functions
我在同一个 Visual Studio 2019 项目中有两个 Azure Functions。从我读到的文档中,将所有函数放在同一个项目中是一个很好的做法。就我而言,它们是预定的和 HTTP 触发的。后一个工作正常,而前一个在我从 Visual Studio 本地调试时显示此错误F5:
无法将参数“$return”绑定到 IActionResult& 类型。确保绑定支持参数类型。如果您使用绑定扩展(例如 Azure 存储、ServiceBus、计时器等),请确保您已在启动代码中调用扩展的注册方法(例如 builder.AddAzureStorage()、builder.AddServiceBus( )、builder.AddTimers() 等)。
这是预定函数的代码:
namespace MyNamespace {
public static class MyFunction {
[FunctionName("Test")]
public static async Task<IActionResult> Run([TimerTrigger("* * 00 * * *")]TimerInfo myTimer, ILogger log) {
return new OkObjectResult("...");
}
}
}
Run Code Online (Sandbox Code Playgroud)
导致错误的原因是什么?
dev*_*crp 10
我相信计时器函数不必返回任何内容。尝试删除并return更改Task<IActionResult>Task
namespace MyNamespace {
public static class MyFunction {
[FunctionName("Test")]
public static async Task Run([TimerTrigger("* * 00 * * *")]TimerInfo myTimer, ILogger log) {
log.LogInformation("...");
// ...
}
}
}
Run Code Online (Sandbox Code Playgroud)