Skip to content

Commit bcb5c39

Browse files
Merge pull request #213023 from Blackmist/config-environment
Config environment
2 parents f014243 + e0f58c2 commit bcb5c39

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+316
-97
lines changed

articles/lab-services/class-type-jupyter-notebook.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ physical_device_desc: "device: 0, name: NVIDIA Tesla K80, pci bus id: 0001:00:00
109109

110110
### Provide notebooks for the class
111111

112-
The next task is to provide students with notebooks that you want them to use. Notebooks can be saved locally on the template VM so each student has their own copy. If you want to use sample notebooks from Azure Machine Learning, see [how to configure an environment with Jupyter Notebooks](../machine-learning/how-to-configure-environment.md#jupyter).
112+
The next task is to provide students with notebooks that you want them to use. Notebooks can be saved locally on the template VM so each student has their own copy. If you want to use sample notebooks from Azure Machine Learning, see [how to configure an environment with Jupyter Notebooks](../machine-learning/how-to-configure-environment.md#jupyter-notebooks).
113113

114114
### Publish the template machine
115115

articles/machine-learning/how-to-configure-environment.md

Lines changed: 46 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ ms.subservice: core
1010
ms.reviewer: larryfr
1111
ms.date: 03/22/2021
1212
ms.topic: how-to
13-
ms.custom: devx-track-python, contperf-fy21q1, devx-track-azurecli, sdkv1, event-tier1-build-2022
13+
ms.custom: devx-track-python, contperf-fy21q1, devx-track-azurecli, event-tier1-build-2022
1414
---
1515

1616
# Set up a Python development environment for Azure Machine Learning
@@ -21,22 +21,22 @@ The following table shows each development environment covered in this article,
2121

2222
| Environment | Pros | Cons |
2323
| --- | --- | --- |
24-
| [Local environment](#local) | Full control of your development environment and dependencies. Run with any build tool, environment, or IDE of your choice. | Takes longer to get started. Necessary SDK packages must be installed, and an environment must also be installed if you don't already have one. |
25-
| [The Data Science Virtual Machine (DSVM)](#dsvm) | Similar to the cloud-based compute instance (Python and the SDK are pre-installed), but with additional popular data science and machine learning tools pre-installed. Easy to scale and combine with other custom tools and workflows. | A slower getting started experience compared to the cloud-based compute instance. |
26-
| [Azure Machine Learning compute instance](#compute-instance) | Easiest way to get started. The entire SDK is already installed in your workspace VM, and notebook tutorials are pre-cloned and ready to run. | Lack of control over your development environment and dependencies. Additional cost incurred for Linux VM (VM can be stopped when not in use to avoid charges). See [pricing details](https://azure.microsoft.com/pricing/details/virtual-machines/linux/). |
24+
| [Local environment](#local-computer-or-remote-vm-environment) | Full control of your development environment and dependencies. Run with any build tool, environment, or IDE of your choice. | Takes longer to get started. Necessary SDK packages must be installed, and an environment must also be installed if you don't already have one. |
25+
| [The Data Science Virtual Machine (DSVM)](#data-science-virtual-machine) | Similar to the cloud-based compute instance (Python is pre-installed), but with additional popular data science and machine learning tools pre-installed. Easy to scale and combine with other custom tools and workflows. | A slower getting started experience compared to the cloud-based compute instance. |
26+
| [Azure Machine Learning compute instance](#azure-machine-learning-compute-instance) | Easiest way to get started. The SDK is already installed in your workspace VM, and notebook tutorials are pre-cloned and ready to run. | Lack of control over your development environment and dependencies. Additional cost incurred for Linux VM (VM can be stopped when not in use to avoid charges). See [pricing details](https://azure.microsoft.com/pricing/details/virtual-machines/linux/). |
2727
| [Azure Databricks](how-to-configure-databricks-automl-environment.md) | Ideal for running large-scale intensive machine learning workflows on the scalable Apache Spark platform. | Overkill for experimental machine learning, or smaller-scale experiments and workflows. Additional cost incurred for Azure Databricks. See [pricing details](https://azure.microsoft.com/pricing/details/databricks/). |
2828

2929
This article also provides additional usage tips for the following tools:
3030

3131
* Jupyter Notebooks: If you're already using Jupyter Notebooks, the SDK has some extras that you should install.
3232

33-
* Visual Studio Code: If you use Visual Studio Code, the [Azure Machine Learning extension](https://marketplace.visualstudio.com/items?itemName=ms-toolsai.vscode-ai) includes extensive language support for Python as well as features to make working with the Azure Machine Learning much more convenient and productive.
33+
* Visual Studio Code: If you use Visual Studio Code, the [Azure Machine Learning extension](https://marketplace.visualstudio.com/items?itemName=ms-toolsai.vscode-ai) includes language support for Python, and features to make working with the Azure Machine Learning much more convenient and productive.
3434

3535
## Prerequisites
3636

3737
* Azure Machine Learning workspace. If you don't have one, you can create an Azure Machine Learning workspace through the [Azure portal](how-to-manage-workspace.md), [Azure CLI](how-to-manage-workspace-cli.md#create-a-workspace), and [Azure Resource Manager templates](how-to-create-workspace-template.md).
3838

39-
### <a id="workspace"></a> Local and DSVM only: Create a workspace configuration file
39+
### Local and DSVM only: Create a workspace configuration file
4040

4141
The workspace configuration file is a JSON file that tells the SDK how to communicate with your Azure Machine Learning workspace. The file is named *config.json*, and it has the following format:
4242

@@ -48,9 +48,9 @@ The workspace configuration file is a JSON file that tells the SDK how to commun
4848
}
4949
```
5050

51-
This JSON file must be in the directory structure that contains your Python scripts or Jupyter Notebooks. It can be in the same directory, a subdirectory named *.azureml*, or in a parent directory.
51+
This JSON file must be in the directory structure that contains your Python scripts or Jupyter Notebooks. It can be in the same directory, a subdirectory named.azureml*, or in a parent directory.
5252

53-
To use this file from your code, use the [`Workspace.from_config`](/python/api/azureml-core/azureml.core.workspace.workspace#from-config-path-none--auth-none---logger-none---file-name-none-) method. This code loads the information from the file and connects to your workspace.
53+
To use this file from your code, use the [`MLClient.from_config`](/python/api/azure-ai-ml/azure.ai.ml.mlclient#azure-ai-ml-mlclient-from-config) method. This code loads the information from the file and connects to your workspace.
5454

5555
Create a workspace configuration file in one of the following methods:
5656

@@ -62,26 +62,25 @@ Create a workspace configuration file in one of the following methods:
6262

6363
* Azure Machine Learning Python SDK
6464

65-
Create a script to connect to your Azure Machine Learning workspace and use the [`write_config`](/python/api/azureml-core/azureml.core.workspace.workspace#write-config-path-none--file-name-none-) method to generate your file and save it as *.azureml/config.json*. Make sure to replace `subscription_id`,`resource_group`, and `workspace_name` with your own.
65+
Create a script to connect to your Azure Machine Learning workspace. Make sure to replace `subscription_id`,`resource_group`, and `workspace_name` with your own.
6666

67-
[!INCLUDE [sdk v1](../../includes/machine-learning-sdk-v1.md)]
67+
[!INCLUDE [sdk v2](../../includes/machine-learning-sdk-v2.md)]
6868

6969
```python
70-
from azureml.core import Workspace
71-
72-
subscription_id = '<subscription-id>'
73-
resource_group = '<resource-group>'
74-
workspace_name = '<workspace-name>'
75-
76-
try:
77-
ws = Workspace(subscription_id = subscription_id, resource_group = resource_group, workspace_name = workspace_name)
78-
ws.write_config()
79-
print('Library configuration succeeded')
80-
except:
81-
print('Workspace not found')
70+
#import required libraries
71+
from azure.ai.ml import MLClient
72+
from azure.identity import DefaultAzureCredential
73+
74+
#Enter details of your AzureML workspace
75+
subscription_id = '<SUBSCRIPTION_ID>'
76+
resource_group = '<RESOURCE_GROUP>'
77+
workspace = '<AZUREML_WORKSPACE_NAME>'
78+
79+
#connect to the workspace
80+
ml_client = MLClient(DefaultAzureCredential(), subscription_id, resource_group, workspace)
8281
```
8382

84-
## <a id="local"></a>Local computer or remote VM environment
83+
## Local computer or remote VM environment
8584

8685
You can set up an environment on a local computer or remote virtual machine, such as an Azure Machine Learning compute instance or Data Science VM.
8786

@@ -96,12 +95,12 @@ To configure a local development environment or remote VM:
9695
> If you're on Linux or macOS and use a shell other than bash (for example, zsh) you might receive errors when you run some commands. To work around this problem, use the `bash` command to start a new bash shell and run the commands there.
9796

9897
1. Activate your newly created Python virtual environment.
99-
1. Install the [Azure Machine Learning Python SDK](/python/api/overview/azure/ml/install).
100-
1. To configure your local environment to use your Azure Machine Learning workspace, [create a workspace configuration file](#workspace) or use an existing one.
98+
1. Install the [Azure Machine Learning Python SDK](/python/api/overview/azure/ai-ml-readme).
99+
1. To configure your local environment to use your Azure Machine Learning workspace, [create a workspace configuration file](#local-and-dsvm-only-create-a-workspace-configuration-file) or use an existing one.
101100

102101
Now that you have your local environment set up, you're ready to start working with Azure Machine Learning. See the [Azure Machine Learning Python getting started guide](tutorial-1st-experiment-hello-world.md) to get started.
103102

104-
### <a id="jupyter"></a>Jupyter Notebooks
103+
### Jupyter Notebooks
105104

106105
When running a local Jupyter Notebook server, it's recommended that you create an IPython kernel for your Python virtual environment. This helps ensure the expected kernel and package import behavior.
107106

@@ -119,10 +118,10 @@ When running a local Jupyter Notebook server, it's recommended that you create a
119118

120119
1. Launch the Jupyter Notebook server
121120

122-
See the [Azure Machine Learning notebooks repository](https://github.com/Azure/MachineLearningNotebooks) to get started with Azure Machine Learning and Jupyter Notebooks.
123-
Also see the community-driven repository, [AzureML-Examples](https://github.com/Azure/azureml-examples).
121+
> [!TIP]
122+
For example notebooks, see the [AzureML-Examples](https://github.com/Azure/azureml-examples) repository. SDK examples are located under [/sdk/python](https://github.com/Azure/azureml-examples/tree/main/sdk/python). For example, the [Configuration notebook](https://github.com/Azure/azureml-examples/blob/main/sdk/python/jobs/configuration.ipynb) example.
124123

125-
### <a id="vscode"></a>Visual Studio Code
124+
### Visual Studio Code
126125

127126
To use Visual Studio Code for development:
128127

@@ -136,11 +135,11 @@ Once you have the Visual Studio Code extension installed, use it to:
136135
* [Run and debug experiments](how-to-debug-visual-studio-code.md)
137136
* [Deploy trained models](tutorial-train-deploy-image-classification-model-vscode.md).
138137

139-
## <a id="compute-instance"></a>Azure Machine Learning compute instance
138+
## Azure Machine Learning compute instance
140139

141140
The Azure Machine Learning [compute instance](concept-compute-instance.md) is a secure, cloud-based Azure workstation that provides data scientists with a Jupyter Notebook server, JupyterLab, and a fully managed machine learning environment.
142141

143-
There is nothing to install or configure for a compute instance.
142+
There's nothing to install or configure for a compute instance.
144143

145144
Create one anytime from within your Azure Machine Learning workspace. Provide just a name and specify an Azure VM type. Try it now with this [Tutorial: Setup environment and workspace](quickstart-create-resources.md).
146145

@@ -153,7 +152,7 @@ In addition to a Jupyter Notebook server and JupyterLab, you can use compute ins
153152

154153
You can also use the Azure Machine Learning Visual Studio Code extension to [connect to a remote compute instance using VS Code](how-to-set-up-vs-code-remote.md).
155154

156-
## <a id="dsvm"></a>Data Science Virtual Machine
155+
## Data Science Virtual Machine
157156

158157
The Data Science VM is a customized virtual machine (VM) image you can use as a development environment. It's designed for data science work that's pre-configured tools and software like:
159158

@@ -193,28 +192,28 @@ To use the Data Science VM as a development environment:
193192
az vm create --resource-group YOUR-RESOURCE-GROUP-NAME --name YOUR-VM-NAME --image microsoft-dsvm:dsvm-windows:server-2016:latest --admin-username YOUR-USERNAME --admin-password YOUR-PASSWORD --authentication-type password
194193
```
195194

196-
1. Activate the conda environment containing the Azure Machine Learning SDK.
195+
1. Create a conda environment for the Azure Machine Learning SDK:
197196

198-
* For Ubuntu Data Science VM:
199-
200-
```bash
201-
conda activate py36
202-
```
203-
204-
* For Windows Data Science VM:
197+
```bash
198+
conda create -n py310 python=310
199+
```
205200

206-
```bash
207-
conda activate AzureML
208-
```
201+
1. Once the environment has been created, activate it and install the SDK
209202

210-
1. To configure the Data Science VM to use your Azure Machine Learning workspace, [create a workspace configuration file](#workspace) or use an existing one.
203+
```bash
204+
conda activate py310
205+
pip install azure-ai-ml
206+
```
211207

212-
Similar to local environments, you can use Visual Studio Code and the [Azure Machine Learning Visual Studio Code extension](#vscode) to interact with Azure Machine Learning.
208+
1. To configure the Data Science VM to use your Azure Machine Learning workspace, [create a workspace configuration file](#local-and-dsvm-only-create-a-workspace-configuration-file) or use an existing one.
213209

214-
For more information, see [Data Science Virtual Machines](https://azure.microsoft.com/services/virtual-machines/data-science-virtual-machines/).
210+
> [!TIP]
211+
> Similar to local environments, you can use Visual Studio Code and the [Azure Machine Learning Visual Studio Code extension](#visual-studio-code) to interact with Azure Machine Learning.
212+
>
213+
> For more information, see [Data Science Virtual Machines](https://azure.microsoft.com/services/virtual-machines/data-science-virtual-machines/).
215214

216215

217216
## Next steps
218217

219218
- [Train and deploy a model](tutorial-train-deploy-notebook.md) on Azure Machine Learning with the MNIST dataset.
220-
- See the [Azure Machine Learning SDK for Python reference](/python/api/overview/azure/ml/intro).
219+
- See the [Azure Machine Learning SDK for Python reference](https://aka.ms/sdk-v2-install).

articles/machine-learning/how-to-create-component-pipeline-python.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ Create a `MLClient` object to manage Azure Machine Learning services.
270270
[!notebook-python[] (~/azureml-examples-v2samplesreorg/sdk/python/jobs/pipelines/2e_image_classification_keras_minist_convnet/image_classification_keras_minist_convnet.ipynb?name=workspace)]
271271
272272
> [!IMPORTANT]
273-
> This code snippet expects the workspace configuration json file to be saved in the current directory or its parent. For more information on creating a workspace, see [Create workspace resources](quickstart-create-resources.md). For more information on saving the configuration to file, see [Create a workspace configuration file](how-to-configure-environment.md#workspace).
273+
> This code snippet expects the workspace configuration json file to be saved in the current directory or its parent. For more information on creating a workspace, see [Create workspace resources](quickstart-create-resources.md). For more information on saving the configuration to file, see [Create a workspace configuration file](how-to-configure-environment.md#local-and-dsvm-only-create-a-workspace-configuration-file).
274274
275275
#### Submit pipeline job to workspace
276276

articles/machine-learning/how-to-deploy-model-cognitive-search.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ An Azure Machine Learning workspace provides a centralized place to work with al
5555
To connect to an existing workspace, use the following code:
5656

5757
> [!IMPORTANT]
58-
> This code snippet expects the workspace configuration to be saved in the current directory or its parent. For more information, see [Create and manage Azure Machine Learning workspaces](how-to-manage-workspace.md). For more information on saving the configuration to file, see [Create a workspace configuration file](how-to-configure-environment.md#workspace).
58+
> This code snippet expects the workspace configuration to be saved in the current directory or its parent. For more information, see [Create and manage Azure Machine Learning workspaces](how-to-manage-workspace.md). For more information on saving the configuration to file, see [Create a workspace configuration file](v1/how-to-configure-environment-v1.md).
5959
6060
```python
6161
from azureml.core import Workspace

0 commit comments

Comments
 (0)