Managing Azure Machine Learning endpoints

Recently, I’ve been working with Azure Machine Learning a lot. It’s fantastic! When the interface works. Unfortunately, It doesn’t always. So, I created a Python package so I could start managing Azure Machine Learning endpoints programmatically.

One of Azure’s features I was - am - most excited about is the ability to easily deploy a trained machine learning model as a webservice. This works great, until you programmatically want to retrain a model with new data. You see, in order to retrain a trained model through a webservice you need to create and update a new endpoint. Unfortunately, managing endpoints through the user interface is totally impossible at the moment. Additionally, the API documentation is nothing to write home about.

This is where the good news starts. Azure automatically generates some API documentation specific to every webservice and every endpoint you create through the machine learning portal. The best part about this is that Azure supplies a basic Swagger JSON file as part of this documentation. This file basically describes most of the generated endpoint API and removes most of the guesswork. After some scripting I figured out all the calls you need to create, delete, get and update a webservice’s endpoints without ever needing the web user interface.

The reactions I got at work and on the Microsoft forums were great. Apparently, there were quite a few people waiting on Microsoft to fix the interface bugs. I bundled my solution as a Python package, gave it a super clever name and made it available for download on PyPI. (Which was a whole new experience by itself, but that’s a story for another time!) To install it via pip, just type:

1
pip install PyZureML

If you’re not into that kind of thing, you could also clone the source directly through git:

1
2
3
git clone git://github.com/marcardioid/PyZureML.git
cd ./PyZureML
python setup.py install

If you decide to do it this way, it’s also super easy to contribute to the source code. (Hint hint!) To use PyZureML - I admit I thought about using AzurePyML as a name - you need Python 3.x and the Requests module. When you have both installed, using PyZureML is super easy. For example, this is how you create and delete an endpoint.

1
2
3
from PyZureML import endpoints
endpoints.create_endpoint(<locale>, <workspace_id>, <api_token>, <webservice_id>, <endpoint_name>, <description>)
endpoints.delete_endpoint(<locale>, <workspace_id>, <api_token>, <webservice_id>, <endpoint_name>)

That’s all for now! I hope you have as much fun teaching computers to do stuff as I’m having.