Skip to content

HTTP status code differs between NoContentResult and ContentResult when Queue Output Binding fails #3269

@aalsamoht

Description

@aalsamoht

Description

When using Azure Functions with both HTTP output and Queue output bindings, the queue binding failure behavior differs based on the type of IActionResult returned. I would expect the HTTP status code to be 500 when writing to the queue fails (due to Connection set to broken-connection-str).

In the included TestFunctions i get the following results:

  • TestFail endpoint (/test/f) using NoContentResult - Returns HTTP 500 👍
  • TestSuccess endpoint (/test/s) using ContentResult - Returns HTTP 200 👎

Steps to reproduce

using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.Functions.Worker;
using Microsoft.Extensions.Logging;

namespace MyProject;

public class TestFunctions
{
    private readonly ILogger<TestFunctions> _logger;

    public TestFunctions(ILogger<TestFunctions> logger)
    {
        _logger = logger;
    }

    // Returns HTTP status code 500
    [Function("TestFail")]
    public TestFunctionOutput RunFail(
        [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = "test/f")]
        HttpRequest req)
    {
        return new TestFunctionOutput
        {
            Result = new NoContentResult(),
            QueueOutput = "Text for the queue"
        };
    }

    // Returns HTTP status code 200
    [Function("TestSuccess")]
    public TestFunctionOutput RunSuccess(
        [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = "test/s")]
        HttpRequest req)
    {
        return new TestFunctionOutput
        {
            Result = new ContentResult
            {
                Content = "<hello>world</hello>", ContentType = "application/xml"
            },
            QueueOutput = "Text for the queue"
        };
    }
    
    public class TestFunctionOutput
    {
        [HttpResult]
        public IActionResult Result { get; init; }

        [QueueOutput("some-queue", Connection = "broken-connection-str")]
        public string QueueOutput { get; init; }
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs: Triage (Functions)potential-bugItems opened using the bug report template, not yet triaged and confirmed as a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions