Azure Machine Learning - endpoint failure 502 when testing the model

Maciej G 41 Reputation points
2022-01-23T10:02:21.937+00:00

Very basic example from ms-learn does not work!!! So frustrating

167468-screenshot-2022-01-23-025300.png

from: https://learn.microsoft.com/en-us/learn/modules/use-automated-machine-learning/

  1. Created a model
  2. model deployment to ACI
  3. I copied the generated py code from the Consume tab into a notebook in the same service
  4. get 502
Azure Machine Learning
Azure Machine Learning
An Azure machine learning service for building and deploying models.
3,340 questions
{count} votes

4 answers

Sort by: Most helpful
  1. [IIJ Global] Yamamoto Mitsuyoshi 21 Reputation points
    2022-03-03T06:37:08.647+00:00

    I've experienced the same problem and I've made the case to the Microsoft support. And I've got the correct Python code as follows.

    The problem come from lack of GlobalParameters in the next sentence.
    input_json = json.dumps({"Inputs":{"data": x}, "GlobalParameters": 1.0})


    endpoint = 'YOUR_ENDPOINT' #Replace with your endpoint
    key = 'YOUR_KEY' #Replace with your key

    import json
    import requests

    An array of features based on five-day weather forecast

    x = [[1,1,2022,1,0,6,0,2,0.344167,0.363625,0.805833,0.160446],
    [2,1,2022,1,0,0,0,2,0.363478,0.353739,0.696087,0.248539],
    [3,1,2022,1,0,1,1,1,0.196364,0.189405,0.437273,0.248309],
    [4,1,2022,1,0,2,1,1,0.2,0.212122,0.590435,0.160296],
    [5,1,2022,1,0,3,1,1,0.226957,0.22927,0.436957,0.1869]]

    Convert the array to JSON format

    input_json = json.dumps({"Inputs":{"data": x}, "GlobalParameters": 1.0})

    Set the content type and authentication for the request

    headers = {"Content-Type":"application/json",
    "Authorization":"Bearer " + key}

    Send the request

    response = requests.post(endpoint, input_json, headers=headers)

    If we got a valid response, display the predictions

    if response.status_code == 200:
    y = response.json()
    print("Predictions:")
    for i in range(len(x)):
    print (" Day: {}. Predicted rentals: {}".format(i+1, max(0, round(y["Results"][i]))))
    else:
    print(response)


    best regards,

    4 people found this answer helpful.

  2. Carlos Granier 6 Reputation points
    2022-02-01T18:14:01.027+00:00

    Additional details:

    Removing:

    ,
        "GlobalParameters": {
        }
    

    from the data variable (in the Endpoints/Consume code) will result in a proper result.

    1 person found this answer helpful.

  3. romungi-MSFT 48,911 Reputation points Microsoft Employee Moderator
    2022-01-24T11:38:32.437+00:00

    @Maciej G Is the deployed service or endpoint in a healthy state? On the Details tab of your endpoint the Deployment state should be healthy and if you also use the test tab the response should be successful.
    I have followed the tutorial and have an endpoint setup which is working as expected with the code from consume tab.

    167836-image.png

    0 comments No comments

  4. Marco Ullasci 1 Reputation point
    2022-03-08T08:58:30.45+00:00

    Thanks @[IIJ Global] Yamamoto Mitsuyoshi for the fix.

    It's quite frustrating that it's not true someone taking a beginners training can follow the advice: "Don't worry too much about the details of the code." (https://learn.microsoft.com/en-us/learn/modules/use-automated-machine-learning/7-deploy-model).
    The persona has to either troubleshoot while the $ counter is running or give up on the exercise.

    BTW it would be great to have sandboxes for AI-900 like there are for DP-900

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.