Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure Functions - RedirectResult causing a HTTP500 error

One of our Azure Functions (running 2.0) should return a RedirectResult (gets triggered by an external webhook, does some processing and should do a redirect to a web page).

This works in our test environment, but does not work when deploying the same function to our production environment. I've tried changing the redirect URL with no luck.

Also wrote a test function like this which still causes a HTTP500 (without logging an exception):

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();
        }
    }
}

So I would think this is some settings outside the actual Function - and would appreciate tips & tricks how to go on about debugging this and get it to work.

like image 230
Kjetil Johannesen Avatar asked Jun 17 '26 13:06

Kjetil Johannesen


1 Answers

There seems to be a bug in runtime version 2.0.12275.0, pinning to 2.0.12246.0 works.

You can change the runtime version in Application Settings of your Function App. Just change the FUNCTIONS_EXTENSION_VERSION key:

enter image description here

like image 186
trydis Avatar answered Jun 19 '26 10:06

trydis



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!