我们的一个 Azure Functions(运行 2.0)应该返回一个 RedirectResult(由外部 webhook 触发,进行一些处理并且应该重定向到网页)。
这在我们的测试环境中有效,但在将相同功能部署到我们的生产环境时无效。我试过更改重定向 URL,但没有成功。
还编写了一个这样的测试函数,它仍然会导致 HTTP500(没有记录异常):
public static class RedirectTest
{
[FunctionName("RedirectTest")]
public static async Task<IActionResult> Run([HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "RedirectTest")] HttpRequest req, ILogger log)
{
try
{
log.LogInformation("Trying to redirect");
return new RedirectResult("https://www.stackoverflow.com");
}
catch (Exception e)
{
log.LogError($"Something bad happened here: {e.Message}", e);
return new OkResult();
}
}
}
所以我认为这是实际功能之外的一些设置 - 并且希望获得有关如何继续调试它并使其正常工作的提示和技巧。
最佳答案
似乎在运行时版本 2.0.12275.0
中存在错误,固定到 2.0.12246.0
有效。
您可以在函数应用程序的应用程序设置中更改运行时版本。只需更改 FUNCTIONS_EXTENSION_VERSION
键:
关于azure-functions - Azure Functions - RedirectResult 导致 HTTP 500 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54291473/