Set up Azure Machine Learning Visual Studio Code extension (preview)

Learn how to install and run scripts using the Azure Machine Learning Visual Studio Code extension.

In this tutorial, you learn the following tasks:

  • Install the Azure Machine Learning Visual Studio Code extension
  • Sign into your Azure account from Visual Studio Code
  • Use the Azure Machine Learning extension to run a sample script


Install the extension

  1. Open Visual Studio Code.

  2. Select Extensions icon from the Activity Bar to open the Extensions view.

  3. In the Extensions view, search for "Azure Machine Learning".

  4. Select Install.

    Install Azure Machine Learning VS Code Extension


Alternatively, you can install the Azure Machine Learning extension via the Visual Studio Marketplace by downloading the installer directly.

The rest of the steps in this tutorial have been tested with version 0.6.8 of the extension.

Sign in to your Azure Account

In order to provision resources and run workloads on Azure, you have to sign in with your Azure account credentials. To assist with account management, Azure Machine Learning automatically installs the Azure Account extension. Visit the following site to learn more about the Azure Account extension.

  1. Open the command palette by selecting View > Command Palette from the menu bar.
  2. Enter the command "Azure: Sign In" into the command palette to start the sign in process.

Run a machine learning model training script in Azure

Now that you have signed into Azure with your account credentials, Use the steps in this section to learn how to use the extension to train a machine learning model.

  1. Download and unzip the VS Code Tools for AI repository anywhere on your computer.

  2. Open the mnist-vscode-docs-sample directory in Visual Studio Code.

  3. Select the Azure icon in the Activity Bar.

  4. Select the Run Experiment icon at the top of the Azure Machine Learning View.

    Run Experiment

  5. When the command palette expands, follow the prompts.


    If you already have existing Azure Machine Learning resources provisioned, see how to run experiments in VS Code guide.

    1. Select your Azure subscription.
    2. From the list of environments, select Conda dependencies file.
    3. Press Enter to browse the Conda dependencies file. This file contains the dependencies required to run your script. In this case, the dependencies file is the env.yml file inside the mnist-vscode-docs-sample directory.
    4. Press Enter to browse the training script file. This is the file that contains code to a machine learning model that categorize images of handwritten digits. In this case, the script to train the model is the file inside the mnist-vscode-docs-sample directory.
  6. At this point, a configuration file similar to the one below appears in the text editor. The configuration contains the information required to run the training job like the file that contains the code to train the model and any Python dependencies specified in the previous step.

        "workspace": "WS06271500",
        "resourceGroup": "WS06271500-rg2",
        "location": "South Central US",
        "experiment": "WS06271500-exp1",
        "compute": {
            "name": "WS06271500-com1",
            "vmSize": "Standard_D1_v2, Cores: 1; RAM: 3.5GB;"
        "runConfiguration": {
            "filename": "WS06271500-com1-rc1",
            "environment": {
                "name": "WS06271500-env1",
                "conda_dependencies": [
                "pip_dependencies": [
                "environment_variables": {}
  7. Once you're satisfied with your configuration, submit your experiment by opening the command palette and entering the following command:

    Azure ML: Submit Experiment

    This sends the and configuration file to your Azure Machine Learning workspace. The training job is then started on a compute resource in Azure.

Track the progress of the training script

Running your script can take several minutes. To track its progress:

  1. Select the Azure icon from the activity bar.

  2. Expand your subscription node.

  3. Expand your currently running experiment's node. This is located inside the {workspace}/Experiments/{experiment} node where the values for your workspace and experiment are the same as the properties defined in the configuration file.

  4. All of the runs for the experiment are listed, as well as their status. To get the most recent status, click the refresh icon at the top of the Azure Machine Learning View.

    Track Experiment Progress

Download the trained model

When the experiment run is complete, the output is a trained model. To download the outputs locally:

  1. Right-click the most recent run and select Download Outputs.

    Download Trained Model

  2. Select a location where to save the outputs to.

  3. A folder with the name of your run is downloaded locally. Navigate to it.

  4. The model files are inside the outputs/outputs/model directory.

Next steps