Anirban Saha
Anirban Saha

Reputation: 1760

How to include a health-check endpoint in a Azure Machine Learning Model deployed as an AKS Webservice?

When we deploy a model using Azure Machine Learning Service, we need a scoring script with at least two functions init which is run once when a model is first deployed and a run function which is run against any data we want to be scored.

The endpoint for this is: http://<IP-Address>/api/v1/service/<Webservice-Name>/score

Is there a way to include a health-check function in the deployed web service? Maybe adding another function healthcheck() and a corresponding endpoint http://<IP-Address>/api/v1/service/<Webservice-Name>/health which when pinged sends us a custom JSON containing information about the health of our service. This may even include information about the Azure Health Check too: enter image description here

Upvotes: 1

Views: 1011

Answers (1)

Daniel Labbe
Daniel Labbe

Reputation: 2019

Apparently, the Azure Machine Learning SDK has to show the properties of the class Webservice. I haven't found any mention to this issue online.

To reproduce fully the experiment, you have to install AML SDK:

pip install azureml-core

And get the workspace:

# get the workspace
subscription_id = '<your_subscription_id>'
resource_group = '<your_resource_group>'
workspace_name = '<your_workspace_name>'
ws = Workspace(subscription_id, resource_group, workspace_name)

Using the Webservice Class, it should work. I have 3 services, but I can't see the status:

# this should work, but it isn't returning the state
for service in Webservice.list(workspace= ws):
    print('Service Name: {} - {}'.format(service.name, service.state)) 
>> Service Name: akstest - None
>> Service Name: regression-model-1 - None
>> Service Name: xgboost-classification-1 - None

Using an intermediate step using the _get() method, it works:

# this works
for service in Webservice.list(workspace= ws):
    service_properties = Webservice._get(workspace= ws, name = service.name)
    print('Service Name: {} - {}'.format(service_properties['name'], service_properties['state']))
>> Service Name: akstest - Failed
>> Service Name: regression-model-1 - Healthy
>> Service Name: xgboost-classification-1 - Healthy

Upvotes: 1

Related Questions