Connect to an Azure Machine Learning compute instance in Visual Studio Code (preview)
In this article, you'll learn how to connect to an Azure Machine Learning compute instance using Visual Studio Code.
An Azure Machine Learning compute instance is a fully managed cloud-based workstation for data scientists and provides management and enterprise readiness capabilities for IT administrators.
There are two ways you can connect to a compute instance from Visual Studio Code:
- Remote compute instance. This option provides you with a full-featured development environment for building your machine learning projects.
- Remote Jupyter Notebook server. This option allows you to set a compute instance as a remote Jupyter Notebook server.
Important
This feature is currently in public preview. This preview version is provided without a service-level agreement, and it's not recommended for production workloads. Certain features might not be supported or might have constrained capabilities. For more information, see Supplemental Terms of Use for Microsoft Azure Previews.
Configure a remote compute instance
To configure a remote compute instance for development, you'll need a few prerequisites.
- Azure Machine Learning Visual Studio Code extension. For more information, see the Azure Machine Learning Visual Studio Code Extension setup guide.
- Azure Machine Learning workspace. Use the Azure Machine Learning Visual Studio Code extension to create a new workspace if you don't already have one.
- Azure Machine Learning compute instance. Use the Azure Machine Learning Visual Studio Code extension to create a new compute instance if you don't have one.
Important
To connect to a compute instance behind a firewall, see Configure inbound and outbound network traffic.
To connect to your remote compute instance:
Navigate to ml.azure.com
Important
In order to connect to your remote compute instance from Visual Studio Code, make sure that the account you're logged into in Azure Machine Learning studio is the same one you use in Visual Studio Code.
Compute
- Select the Compute tab
- In the Application URI column, select VS Code for the compute instance you want to connect to.
Notebook
- Select the Notebook tab
- In the Notebook tab, select the file you want to edit.
- Select Editors > Edit in VS Code (preview).
A new window launches for your remote compute instance. When attempting to make a connection to a remote compute instance, the following tasks are taking place:
- Authorization. Some checks are performed to make sure the user attempting to make a connection is authorized to use the compute instance.
- VS Code Remote Server is installed on the compute instance.
- A WebSocket connection is established for real-time interaction.
Once the connection is established, it's persisted. A token is issued at the start of the session which gets refreshed automatically to maintain the connection with your compute instance.
After you connect to your remote compute instance, use the editor to:
- Author and manage files on your remote compute instance or file share.
- Use the VS Code integrated terminal to run commands and applications on your remote compute instance.
- Debug your scripts and applications
- Use VS Code to manage your Git repositories
Configure compute instance as remote notebook server
In order to configure a compute instance as a remote Jupyter Notebook server you'll need a few prerequisites:
- Azure Machine Learning Visual Studio Code extension. For more information, see the Azure Machine Learning Visual Studio Code Extension setup guide.
- Azure Machine Learning workspace. Use the Azure Machine Learning Visual Studio Code extension to create a new workspace if you don't already have one.
To connect to a compute instance:
Open a Jupyter Notebook in Visual Studio Code.
When the integrated notebook experience loads, select Jupyter Server.
Alternatively, you also use the command palette:
- Open the command palette by selecting View > Command Palette from the menu bar.
- Enter into the text box
AzureML: Connect to Compute instance Jupyter server
.
Choose
Azure Machine Learning Compute Instances
from the list of Jupyter server options.Select your subscription from the list of subscriptions. If you have have previously configured your default Azure Machine Learning workspace, this step is skipped.
Select your workspace.
Select your compute instance from the list. If you don't have one, select Create new Azure Machine Learning Compute Instance and follow the prompts to create one.
For the changes to take effect, you have to reload Visual Studio Code.
Open a Jupyter Notebook and run a cell.
Important
You MUST run a cell in order to establish the connection.
At this point, you can continue to run cells in your Jupyter Notebook.
Tip
You can also work with Python script files (.py) containing Jupyter-like code cells. For more information, see the Visual Studio Code Python interactive documentation.
Next steps
Now that you've set up Visual Studio Code Remote, you can use a compute instance as remote compute from Visual Studio Code to interactively debug your code.
Tutorial: Train your first ML model shows how to use a compute instance with an integrated notebook.
Feedback
Submit and view feedback for