ADF Function Activities fail to return response body with 400/500 status codes

Scoot-3223 71 Reputation points
2022-11-17T01:52:27.513+00:00

Why does a ADF pipeline's function activity omit the response body when a 400/500 status code is returned, while the response body is returned with the same function is run directly from a function app?

I have a simple python test function, shown below, that executes as expected as a standalone function. The 500 status_code AND the response body are returned. However, when this function is executed in a data factory pipeline function activity, the payload is dropped.

I'd like to use 500 status codes to enable error handling in my function based pipelines, and to capture a raised exception which is excluded here for simplicity.

Thanks,
Scott

Simple test function:

import azure.functions as func

def main(req: func.HttpRequest) -> func.HttpResponse:

return func.HttpResponse("Exception was raised", status_code=500)

P.S. In researching this ADF anomaly I found this which confirms what I see in the ADF: https://stackoverflow.com/questions/61949996/why-is-azure-api-management-hides-response-body-for-status-codes-4-and-5. This seems like the issue but I have no idea how to test a solution.

While this link confirms what I see when running a stand alone function: https://learn.microsoft.com/en-us/answers/questions/509540/why-do-azure-functions-report-success-if-http-500.html

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
3,005 questions
Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
7,139 questions
0 comments No comments
{count} votes

Accepted answer
  1. MartinJaffer-MSFT 25,711 Reputation points
    2022-11-17T21:39:04.56+00:00

    Hello @Scoot-3223 and welcome to Microsoft Q&A.

    Thank you for such a well written question. I see you have done some research already.

    I used your simple test function to repro the issue, with 1 alteration; I added my name to the message so I can differentiate from some standard message. However, I saw the exception message was returned! I tested this with both Web Activity and Azure Function Activity in ADF. I see it in "Error details" rather than "Output". I tested with both a debug run and a "trigger now".

    The Function Activity's, error:

    Call to provided Azure function 'FailHttp' failed with status-'InternalServerError' while invoking 'GET' on 'https://failfunc.azurewebsites.net' and message - 'Martin's Exception was raised'.

    func-error-snapshot

    The Web activity's error:

    Martin's Exception was raised

    web-error-snapshot

    I know you didn't say anything about Web activity, but I like to use it for comparison.

    Since our experiences differed so wildly, I'd like to verify whether you were checking the output or the errors for your response body. ... ohh, now I get what you are asking! You are asking about the design decision to make the same message component have different jsonpath depending upon response code.
    Yes, technically, the response body is the response body no matter the error code from a raw point of view.

    However having them different protects code assuming success from running on error message instead of data.

    Also, with the design decision to make status codes 400/500 result in an activity failure, we want the Function activity to behave similar to how other activities behave on failure/error behavior. Make the failure/error output align across different activities. To this end, we need a error message or other detail to pass along with the code. While we could put a standard explanation of the status code, using the response body is richer and respects the endpoint's intent more. Where else could the error message come from?

    Did I answer your question, or are you really missing the message even in the error class? I wonder if there is a character limit to that. Stack traces can get very large.

    Hope this will help. Please let us know if any further queries.

    ------------------------------

    • Please don't forget to click on 130616-image.png or upvote 130671-image.png button whenever the information provided helps you. Original posters help the community find answers faster by identifying the correct answer. Here is how
    • Want a reminder to come back and check responses? Here is how to subscribe to a notification
    • If you are interested in joining the VM program and help shape the future of Q&A: Here is how you can be part of Q&A Volunteer Moderators

0 additional answers

Sort by: Most helpful