Azure函数-RedirectResult导致HTTP500错误

时间:2019-01-21 13:54:11

标签: azure-functions

我们的一个Azure函数(运行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 :(得分:1)

运行时版本2.0.12275.0中似乎存在一个错误,将其固定到2.0.12246.0即可。

您可以在Function App的Application Settings中更改运行时版本。只需更改FUNCTIONS_EXTENSION_VERSION键:

enter image description here

答案 1 :(得分:0)

要在本地计算机上执行此操作,您需要获取 https://github.com/Azure/azure-functions-core-tools/releases/tag/2.3.199 该工具包含运行时2.0.12246.0

choco install azure-functions-core-tools --version 2.3.199

相关问题