Azure Function Timer Trigger & API 管理 - 手动执行 returns 404

Azure Function Timer Trigger & API management - Manual execution returns 404

我有一个功能应用程序:

我还为函数应用程序设置了 Azure API 管理 服务,其中 HTTP 触发 函数具有他们的端点已定义。

我正在尝试按照此处的指南手动触发我的定时器触发功能之一 https://docs.microsoft.com/en-us/azure/azure-functions/functions-manually-run-non-http

尽管 URL 和 x-functions-key.

看似正确,但我在 Postman 中得到了 404 结果

函数:

关键:

要求:

我还注意到:

会不会和函数应用设置的API管理服务有关?

如何进一步解决此问题?

我在身边测试过,没问题。请参考以下截图:

请检查您是否请求 https://xxx.azurewebsites.net/admin/functions/TimerTrigger1 而不是 https://xxx.azurewebsites.net/admin/functions/TimerTrigger。请注意它是“TimerTrigger1”。

我在第一次测试时请求 ..../TimerTrigger,因为文档向我们显示 QueueTrigger,它响应 404。

我已经解决了。

事实证明,Azure Functions 计时器触发器需要 六部分 cron 表达式(我只知道 the five part style

没有它,它就无法工作 - 遗憾的是,这在 UI 中不容易被注意到。 我已经意识到,通过调查 Application Insights 日志:

功能页面显示一切正常:

更改 CRON 格式已解决 404 问题,我开始收到 202 Accepted 响应。

作为奖励,我必须添加:

即使响应为 202 Accepted,触发也无法正常工作,因为 我的函数 return 类型是 Task<IActionResult>,定时器触发函数不接受该类型。

同样,只有 ApplicationInsights 显示有任何问题:

The 'MonkeyUserRandom' function is in error: Microsoft.Azure.WebJobs.Host: Error indexing method 'MonkeyUserRandom'. Microsoft.Azure.WebJobs.Host: Cannot bind parameter '$return' to type IActionResult&. Make sure the parameter Type is supported by the binding. If you're using binding extensions (e.g. Azure Storage, ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (e.g. builder.AddAzureStorage(), builder.AddServiceBus(), builder.AddTimers(), etc.).

这是 'manual triggering of non-http function does not work' 的额外小费。