KeyError 'raw_data'

Adam Makhlouf 1 Reputation point

Hi there,

I am testing my deployed model on AKS using Postman. To be able to do so, I do a kubectl port-forward on an azureml-fe pod (toward port 8001). My deployment is successful, I am also able to get the swagger documentation interrogating my model.

However, when running a request on the /score endpoint I get an error linked to azure libraries. Here are the logs from the pod. I get the error even with a very simple run function that just returns a fixed value like

@input_schema('input_data', sample_input)
def run(input_data):
    return json.dumps({"hello":"world"})

Here are logs.

2022-04-08 15:44:28,832 | root | INFO | Validation Request Content-Type
2022-04-08 15:44:28,833 | root | ERROR | Encountered Exception: Traceback (most recent call last):
  File "/var/azureml-server/synchronous/", line 65, in run_scoring
    response, time_taken_ms = invoke_user_with_timer(service_input, request_headers)
  File "/var/azureml-server/synchronous/", line 102, in invoke_user_with_timer
    params = prepare_user_params(input, headers, aml_request._rawHttpRequested)
  File "/var/azureml-server/", line 132, in prepare_user_params
    params = {main.run_input_parameter_name: input[main.wrapped_parameter_name]}
KeyError: 'raw_data'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/azureml-envs/azureml_61774fe85dfca66c0af06d4aa0c015f2/lib/python3.8/site-packages/flask/", line 1832, in full_dispatch_request
    rv = self.dispatch_request()
  File "/azureml-envs/azureml_61774fe85dfca66c0af06d4aa0c015f2/lib/python3.8/site-packages/flask/", line 1818, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/var/azureml-server/synchronous/", line 44, in score_realtime
    return run_scoring(service_input, request.headers, request.environ.get('REQUEST_ID', '00000000-0000-0000-0000-000000000000'))
  File "/var/azureml-server/synchronous/", line 74, in run_scoring
    raise RunFunctionException(str(exc))

2022-04-08 15:44:28,834 | root | INFO | 500 - - [08/Apr/2022:15:44:28 +0000] "POST /score HTTP/1.0" 500 10 "-" "PostmanRuntime/7.29.0"

Could you please help?

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

1 answer

Sort by: Most helpful
  1. Adam Makhlouf 1 Reputation point

    It is not well explained here but the solution was actually simple. When you use @input_schema('input_data')

    Your POST request should be of the form.

    data = {  
        "input_data": {  
            "first_key": value,  
            "second_key": value  
    0 comments No comments