Search code examples
azureazure-functionsazure-functions-runtime

BadRequestObjectResult does not return detailed error message to the client


I have a Azure function with an HTTP trigger. It produces a 400 response when an input value is not specified:

if (string.IsNullOrEmpty(artistName))
{
    return new BadRequestObjectResult("Artist name not specified.");
}

When the function is running locally (func host start) and the API is called incorrectly (I am using curl -X POST ...), the above error message is shown.

When deployed to Azure and called in a similar way - instead of the detailed error message - only Bad Request is returned.

Why?
How can I change this behaviour?


Solution

  • It's a known issue for function runtime 2.0.11888 that HttpTrigger does not return response content properly.

    If you want to solve this, go to Application settings, pin your FUNCTIONS_EXTENSION_VERSION to previous runtime 2.0.11857-alpha until new version is released.

    See Azure Functions Runtime 2.0.11888 Preview.

    Update

    This issue has already been fixed from 2.0.11933.