This is part two in a series on getting beyond the basics with Azure ML.

Making Things Personal

Notebooks are great for ad hoc work or simple data analysis but we will want more robust tools if we wish to perform proper code development, testing, and deployment. This is where Visual Studio Code comes into play, particularly the Azure Machine Learning extension.

Four-point-something stars of quality.

What this extension does is that it provides you a direct interface to your Azure ML workspace after you sign in with a valid Azure account. It also allows you to turn a local machine into a compute instance if you have Docker installed on the machine. Here’s an example of me connecting to my CSAzureML workspace.

All of the penguin endpoints we could ever need.

The Visual Studio Code extension includes links to most of the Azure ML objects we care about, including Datastores & Datasets, Experiments & Models, Endpoints, Compute, and Environments.

To make it easy to understand what we’re doing, let’s start off easy and re-run the same notebook as we did in Azure ML.

Running a Notebook

Visual Studio Code includes a Jupyter notebook environment, meaning that you can execute notebook code here like you would in your Azure ML compute instance. We will first need to select a valid Python kernel.

So many kernels.

Next up, you might need a file called config.json. Note that in my case, I’ve explicitly added this file .gitignore because I don’t want this checked into source control. It contains information regarding your subscription that you probably don’t want in GitHub.

Not the type of thing you want getting around.

You’ll create a config.json file with the following content:

{"Id": null, "Scope": "/subscriptions/<SUBSCRIPTION_ID>/resourceGroups/<RESOURCE_GROUP>/providers/Microsoft.MachineLearningServices/workspaces/<WORKSPACE_NAME>"}

Replace the tokens <SUBSCRIPTION_ID>, <RESOURCE_GROUP>, and <WORKSPACE_NAME> with your values and then you should be able to run notebook code.

Executing Remote Compute

Suppose that you want to use Visual Studio Code to execute notebooks but you’d still like to use the compute instance for remote compute. An example of why might be because you have GPU resources on the compute instance but not your local machine. Microsoft has instructions on how to do that as well.

This also makes it easy to store your notebooks and code in source control while allowing the compute instance to do your machine learning work.

Conclusion

Today’s post was a fairly simple one, intended to introduce you to the idea of performing all of your work outside of Azure ML. In the next post, we will spend a bit more time looking at what the Python SDK has to offer us. As we continue on this series, the benefits of writing our code outside of Azure ML Studio will become more and more obvious.

3 thoughts on “Beyond the Basics with Azure ML: Working with VS Code

Leave a comment