How to specify HTTP response status code in AML R Web Service

Lauri Lehman 136 Reputation points
2021-02-03T12:21:00.267+00:00

Is there any way to return a custom HTTP status code from R Web Service in Azure ML?

All the examples of entry scripts in documentation return the response body from the scoring function. In Python Web Service, it is possible to return a HTTP response object with a custom status code. However, R's httr library does not seem to have any function to create response objects directly (only via HTTP method objects such as POST, which call a given URL).

I would like to implement a custom exception handling scheme in R Web Service. Is there any way to return a custom HTTP code from the entry script?

EDIT: Found this idea on the feedback forum, which suggests that the option is not available in Python Web Service either:
https://feedback.azure.com/forums/257792-machine-learning/suggestions/40122838-make-http-status-codes-controllable-from-your-scor

Azure Machine Learning
Azure Machine Learning
An Azure machine learning service for building and deploying models.
2,618 questions
0 comments No comments
{count} votes

2 additional answers

Sort by: Most helpful
  1. Lauri Lehman 136 Reputation points
    2021-02-03T19:17:19.37+00:00

    I found that it is possible to return "502 Replica failed" by raising an exception in the entry script. However, it would still be nice to be able to return custom status codes.

    0 comments No comments

  2. Bozhong Lin 1 Reputation point
    2021-02-05T01:56:45.177+00:00

    This sample shows how to return custom StatusCode (returns 200 or 500):
    https://learn.microsoft.com/en-us/azure/machine-learning/how-to-deploy-advanced-entry-script#binary-data