Create an Azure Machine Learning service workspace

To use Azure Machine Learning service, you need an Azure Machine Learning service workspace. This workspace is the top-level resource for the service and provides you with a centralized place to work with all the artifacts you create.

In this article, you learn how to create a workspace using any of these methods:

The workspace you create using the steps here-in can be used as a prerequisite to other tutorials and how-to articles.

If you would like to use a script to setup automated machine learning in a local Python environment please refer to the Azure/MachineLearningNotebooks GitHub for instructions.

When you create a workspace the following Azure resources are added automatically (if they're regionally available):

Note

As with other Azure services, certain limits and quotas are associated with Machine Learning. Learn about quotas and how to request more.

Prerequisites

To create a workspace, you need an Azure subscription. If you don’t have an Azure subscription, create a free account before you begin. Try the free or paid version of Azure Machine Learning service today.

Azure portal

  1. Sign in to the Azure portal by using the credentials for the Azure subscription you use.

    Azure portal

  2. In the upper-left corner of the portal, select Create a resource.

    Create a resource in Azure portal

  3. In the search bar, enter Machine Learning. Select the Machine Learning service workspace search result.

    Search for a workspace

  4. In the ML service workspace pane, select Create to begin.

    Create button

  5. In the ML service workspace pane, configure your workspace.

    Field Description
    Workspace name Enter a unique name that identifies your workspace. In this example, we use docs-ws. Names must be unique across the resource group. Use a name that's easy to recall and differentiate from workspaces created by others.
    Subscription Select the Azure subscription that you want to use.
    Resource group Use an existing resource group in your subscription, or enter a name to create a new resource group. A resource group holds related resources for an Azure solution. In this example, we use docs-aml.
    Location Select the location closest to your users and the data resources. This location is where the workspace is created.

    Create workspace

  6. To start the creation process, select Review + Create.

    Create

  7. Review your workspace configuration. If it is correct, select Create. It can take a few moments to create the workspace.

    Create

  8. To check on the status of the deployment, select the Notifications icon, bell, on the toolbar.

  9. When the process is finished, a deployment success message appears. It's also present in the notifications section. To view the new workspace, select Go to resource.

    Workspace creation status

No matter how it was created, you can view your workspace in the Azure portal. See view a workspace for details.

Python SDK

Create your workspace using the Python SDK. First you need to install the SDK.

Important

Skip installation of the SDK if you use an Azure Data Science Virtual Machine or Azure Databricks.

Note

Use these instructions to install and use the SDK from your local computer. To use Jupyter on a remote virtual machine, set up a remote desktop or X terminal session.

Before you install the SDK, we recommend that you create an isolated Python environment. Although this article uses Miniconda, you can also use full Anaconda installed or Python virtualenv.

The instructions in this article will install all the packages you need to run the quickstart and tutorial notebooks. Other sample notebooks may require installation of additional components. For more information about these components, see Install the Azure Machine Learning SDK for Python.

Install Miniconda

Download and install Miniconda. Select the Python 3.7 version to install. Don't select the Python 2.x version.

Create an isolated Python environment

  1. Open Anaconda Prompt , then create a new conda environment named myenv and install Python 3.6.5. Azure Machine Learning SDK will work with Python 3.5.2 or later, but the automated machine learning components are not fully functional on Python 3.7. It will take several minutes to create the environment while components and packages are downloaded.

    conda create -n myenv python=3.6.5
    
  2. Activate the environment.

    conda activate myenv
    
  3. Enable environment-specific ipython kernels:

    conda install notebook ipykernel
    

    Then create the kernel:

    ipython kernel install --user
    

Install the SDK

  1. In the activated conda environment, install the core components of the Machine Learning SDK with Jupyter notebook capabilities. The installation takes a few minutes to finish based on the configuration of your machine.

    pip install --upgrade azureml-sdk[notebooks]
    
  2. To use this environment for the Azure Machine Learning tutorials, install these packages.

    conda install -y cython matplotlib pandas
    
  3. To use this environment for the Azure Machine Learning tutorials, install the automated machine learning components.

    pip install --upgrade azureml-sdk[automl]
    

Important

In some command-line tools, you might need to add quotation marks as follows:

  • 'azureml-sdk[notebooks]'
  • 'azureml-sdk[automl]'

Create a workspace with the SDK

Create your workspace in a Jupyter Notebook using the Python SDK.

  1. Create and/or cd to the directory you want to use for the quickstart and tutorials.

  2. To launch Jupyter Notebook, enter this command:

    jupyter notebook
    
  3. In the browser window, create a new notebook by using the default Python 3 kernel.

  4. To display the SDK version, enter and then execute the following Python code in a notebook cell:

    import azureml.core
    print(azureml.core.VERSION)
    
  5. Find a value for the <azure-subscription-id> parameter in the subscriptions list in the Azure portal. Use any subscription in which your role is owner or contributor. For more information on roles, see Manage access to an Azure Machine Learning workspace article.

    from azureml.core import Workspace
    ws = Workspace.create(name='myworkspace',
                          subscription_id='<azure-subscription-id>',	
                          resource_group='myresourcegroup',
                          create_resource_group=True,
                          location='eastus2' 
                         )
    

    When you execute the code, you might be prompted to sign into your Azure account. After you sign in, the authentication token is cached locally.

  6. To view the workspace details, such as associated storage, container registry, and key vault, enter the following code:

    ws.get_details()
    

Write a configuration file

Save the details of your workspace in a configuration file to the current directory. This file is called .azureml/config.json.

This workspace configuration file makes it easy to load the same workspace later. You can load it with other notebooks and scripts in the same directory or a subdirectory using the code ws=Workspace.from_config() .

# Create the configuration file.
ws.write_config()

# Use this code to load the workspace from 
# other scripts and notebooks in this directory.
# ws = Workspace.from_config()

This write_config() API call creates the configuration file in the current directory. The .azureml/config.json file contains the following:

{
    "subscription_id": "<azure-subscription-id>",
    "resource_group": "myresourcegroup",
    "workspace_name": "myworkspace"
}

Tip

To use your workspace in Python scripts or Jupyter Notebooks located in other directories, copy this file to that directory. The file can be in the same directory, a subdirectory named .azureml, or in a parent directory.

Resource manager template

To create a workspace with a template, see Create an Azure Machine Learning service workspace by using a template

Command-line interface

To create a workspace with the CLI, see Use the CLI extension for Azure Machine Learning service.

Clean up resources

Important

The resources you created can be used as prerequisites to other Azure Machine Learning service tutorials and how-to articles.

If you don't plan to use the resources you created, delete them, so you don't incur any charges:

  1. In the Azure portal, select Resource groups on the far left.

    Delete in the Azure portal

  2. From the list, select the resource group you created.

  3. Select Delete resource group.

  4. Enter the resource group name. Then select Delete.

Next steps