Skip to content

Commit 0be01f1

Browse files
authored
Merge pull request #267496 from sdgilley/sdg-freshness2
Freshness update concept-azure-machine-learning-v2
2 parents c6c2554 + 6de43ca commit 0be01f1

File tree

1 file changed

+126
-95
lines changed

1 file changed

+126
-95
lines changed

articles/machine-learning/concept-azure-machine-learning-v2.md

Lines changed: 126 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ ms.topic: conceptual
1010
ms.author: balapv
1111
author: balapv
1212
ms.reviewer: sgilley
13-
ms.date: 11/04/2022
13+
ms.date: 02/27/2024
1414
#Customer intent: As a data scientist, I want to understand the big picture about how Azure Machine Learning works.
1515
---
1616

@@ -34,23 +34,57 @@ Azure Machine Learning includes several resources and assets to enable you to pe
3434

3535
This document provides a quick overview of these resources and assets.
3636

37-
## Workspace
37+
## Prerequisites
3838

39-
The workspace is the top-level resource for Azure Machine Learning, providing a centralized place to work with all the artifacts you create when you use Azure Machine Learning. The workspace keeps a history of all jobs, including logs, metrics, output, and a snapshot of your scripts. The workspace stores references to resources like datastores and compute. It also holds all assets like models, environments, components and data asset.
39+
### [Python SDK](#tab/sdk)
4040

41-
### Create a workspace
41+
To use the Python SDK code examples in this article:
42+
43+
1. Install the [Python SDK v2](https://aka.ms/sdk-v2-install)
44+
2. Create a connection to your Azure Machine Learning subscription. The examples all rely on `ml_client`. To create a workspace, the connection does not need a workspace name, since you may not yet have one. All other examples in this article require that the workspace name is included in the connection.
45+
46+
```python
47+
# import required libraries
48+
from azure.ai.ml import MLClient
49+
from azure.ai.ml.entities import Workspace
50+
from azure.identity import DefaultAzureCredential
51+
52+
# Enter details of your subscription
53+
subscription_id = "<SUBSCRIPTION_ID>"
54+
resource_group = "<RESOURCE_GROUP>"
55+
56+
# get a handle to the subscription (use this if you haven't created a workspace yet)
57+
ml_client = MLClient(DefaultAzureCredential(), subscription_id, resource_group)
58+
59+
# all other examples in this article require the connection to include workspace name
60+
workspace_name = "<WORKSPACE_NAME>"
61+
ml_client = ml_client = MLClient(DefaultAzureCredential(), subscription_id, resource_group, workspace_name)
62+
```
4263

4364
### [Azure CLI](#tab/cli)
4465

45-
To create a workspace using CLI v2, use the following command:
66+
To use the Azure CLI code examples in this article, you need to have the Azure CLI installed and configured. You can install the Azure CLI from the [Install and set up the CLI (v2)](how-to-configure-cli.md).
4667

47-
[!INCLUDE [cli v2](includes/machine-learning-cli-v2.md)]
68+
Once you have the Azure CLI installed, sign in to your Azure account:
69+
70+
:::code language="azurecli" source="~/azureml-examples-main/cli/misc.sh" id="az_login":::
71+
72+
If you have access to multiple Azure subscriptions, you set your active subscription:
73+
74+
:::code language="azurecli" source="~/azureml-examples-main/cli/misc.sh" id="az_account_set":::
4875

49-
```bash
50-
az ml workspace create --file my_workspace.yml
51-
```
5276

53-
For more information, see [workspace YAML schema](reference-yaml-workspace.md).
77+
### [Studio](#tab/azure-studio)
78+
79+
Sign in to [Azure Machine Learning studio](https://ml.azure.com).
80+
81+
---
82+
83+
## Workspace
84+
85+
The workspace is the top-level resource for Azure Machine Learning, providing a centralized place to work with all the artifacts you create when you use Azure Machine Learning. The workspace keeps a history of all jobs, including logs, metrics, output, and a snapshot of your scripts. The workspace stores references to resources like datastores and compute. It also holds all assets like models, environments, components and data asset.
86+
87+
### Create a workspace
5488

5589
### [Python SDK](#tab/sdk)
5690

@@ -59,48 +93,53 @@ To create a workspace using Python SDK v2, you can use the following code:
5993
[!INCLUDE [sdk v2](includes/machine-learning-sdk-v2.md)]
6094

6195
```python
62-
ws_basic = Workspace(
63-
name="my-workspace",
64-
location="eastus", # Azure region (location) of workspace
65-
display_name="Basic workspace-example",
66-
description="This example shows how to create a basic workspace"
96+
# specify the workspace details
97+
ws = Workspace(
98+
name="my_workspace",
99+
location="eastus",
100+
display_name="My workspace",
101+
description="This example shows how to create a workspace",
102+
tags=dict(purpose="demo"),
67103
)
68-
ml_client.workspaces.begin_create(ws_basic) # use MLClient to connect to the subscription and resource group and create workspace
104+
105+
ml_client.workspaces.begin_create(ws) # use MLClient to connect to the subscription and resource group and create workspace
69106
```
70107

71108
This [Jupyter notebook](https://github.com/Azure/azureml-examples/blob/main/sdk/python/resources/workspace/workspace.ipynb) shows more ways to create an Azure Machine Learning workspace using SDK v2.
72109

73-
---
74-
75-
## Compute
110+
### [Azure CLI](#tab/cli)
76111

77-
A compute is a designated compute resource where you run your job or host your endpoint. Azure Machine Learning supports the following types of compute:
112+
To create a workspace using CLI v2, use the following command:
78113

79-
* **Compute cluster** - a managed-compute infrastructure that allows you to easily create a cluster of CPU or GPU compute nodes in the cloud.
114+
[!INCLUDE [cli v2](includes/machine-learning-cli-v2.md)]
80115

81-
[!INCLUDE [serverless compute](./includes/serverless-compute.md)]
116+
```bash
117+
az ml workspace create --file my_workspace.yml
118+
```
82119

83-
* **Compute instance** - a fully configured and managed development environment in the cloud. You can use the instance as a training or inference compute for development and testing. It's similar to a virtual machine on the cloud.
84-
* **Inference cluster** - used to deploy trained machine learning models to Azure Kubernetes Service. You can create an Azure Kubernetes Service (AKS) cluster from your Azure Machine Learning workspace, or attach an existing AKS cluster.
85-
* **Attached compute** - You can attach your own compute resources to your workspace and use them for training and inference.
120+
For the content of the file, see [workspace YAML examples](https://github.com/Azure/azureml-examples/tree/main/cli/resources/workspace).
86121

122+
### [Studio](#tab/azure-studio)
87123

88-
### [Azure CLI](#tab/cli)
124+
Create a workspace in the studio welcome page by selecting **Create workspace**.
89125

90-
To create a compute using CLI v2, use the following command:
126+
---
91127

92-
[!INCLUDE [cli v2](includes/machine-learning-cli-v2.md)]
128+
## Compute
93129

94-
```bash
95-
az ml compute --file my_compute.yml
96-
```
130+
A compute is a designated compute resource where you run your job or host your endpoint. Azure Machine Learning supports the following types of compute:
97131

98-
For more information, see [compute YAML schema](reference-yaml-overview.md#compute).
132+
* **Compute instance** - a fully configured and managed development environment in the cloud. You can use the instance as a training or inference compute for development and testing. It's similar to a virtual machine on the cloud.
133+
* **Compute cluster** - a managed-compute infrastructure that allows you to easily create a cluster of CPU or GPU compute nodes in the cloud.
134+
* **Serverless compute** - a compute cluster you access on the fly. When you use serverless compute, you don't need to create your own cluster. All compute lifecycle management is offloaded to Azure Machine Learning.
135+
* **Inference cluster** - used to deploy trained machine learning models to Azure Kubernetes Service. You can create an Azure Kubernetes Service (AKS) cluster from your Azure Machine Learning workspace, or attach an existing AKS cluster.
136+
* **Attached compute** - You can attach your own compute resources to your workspace and use them for training and inference.
99137

138+
### Create a compute
100139

101140
### [Python SDK](#tab/sdk)
102141

103-
To create a compute using Python SDK v2, you can use the following code:
142+
To create a compute cluster using Python SDK v2, you can use the following code:
104143

105144
[!INCLUDE [sdk v2](includes/machine-learning-sdk-v2.md)]
106145

@@ -119,6 +158,26 @@ ml_client.begin_create_or_update(cluster_basic)
119158

120159
This [Jupyter notebook](https://github.com/Azure/azureml-examples/blob/main/sdk/python/resources/compute/compute.ipynb) shows more ways to create compute using SDK v2.
121160

161+
### [Azure CLI](#tab/cli)
162+
163+
To create a compute using CLI v2, use the following command:
164+
165+
[!INCLUDE [cli v2](includes/machine-learning-cli-v2.md)]
166+
167+
```bash
168+
az ml compute create --file my_compute.yml
169+
```
170+
171+
For the content of the file, see [compute YAML examples](https://github.com/Azure/azureml-examples/tree/main/cli/resources/compute).
172+
.
173+
174+
### [Studio](#tab/azure-studio)
175+
176+
1. Select a workspace if you are not already in one.
177+
1. From the left-hand menu, select **Compute**.
178+
1. On the top, select a tab to specify the type of compute you want to create.
179+
1. Select **New** to create the new compute.
180+
122181
---
123182

124183
## Datastore
@@ -130,17 +189,7 @@ Azure Machine Learning datastores securely keep the connection information to yo
130189
* Azure Data Lake
131190
* Azure Data Lake Gen2
132191

133-
### [Azure CLI](#tab/cli)
134-
135-
To create a datastore using CLI v2, use the following command:
136-
137-
[!INCLUDE [cli v2](includes/machine-learning-cli-v2.md)]
138-
139-
```bash
140-
az ml datastore create --file my_datastore.yml
141-
```
142-
For more information, see [datastore YAML schema](reference-yaml-overview.md#datastore).
143-
192+
### Create a datastore
144193

145194
### [Python SDK](#tab/sdk)
146195

@@ -149,8 +198,10 @@ To create a datastore using Python SDK v2, you can use the following code:
149198
[!INCLUDE [sdk v2](includes/machine-learning-sdk-v2.md)]
150199

151200
```python
201+
import AzureBlobDatastore
202+
152203
blob_datastore1 = AzureBlobDatastore(
153-
name="blob-example",
204+
name="blob_example",
154205
description="Datastore pointing to a blob container.",
155206
account_name="mytestblobstore",
156207
container_name="data-container",
@@ -163,49 +214,40 @@ ml_client.create_or_update(blob_datastore1)
163214

164215
This [Jupyter notebook](https://github.com/Azure/azureml-examples/blob/main/sdk/python/resources/datastores/datastore.ipynb) shows more ways to create datastores using SDK v2.
165216

166-
---
167-
168-
## Model
169-
170-
Azure machine learning models consist of the binary file(s) that represent a machine learning model and any corresponding metadata. Models can be created from a local or remote file or directory. For remote locations `https`, `wasbs` and `azureml` locations are supported. The created model will be tracked in the workspace under the specified name and version. Azure Machine Learning supports three types of storage format for models:
171-
172-
* `custom_model`
173-
* `mlflow_model`
174-
* `triton_model`
175-
176-
### Creating a model
177-
178217
### [Azure CLI](#tab/cli)
179218

180-
To create a model using CLI v2, use the following command:
219+
To create a datastore using CLI v2, use the following command:
181220

182221
[!INCLUDE [cli v2](includes/machine-learning-cli-v2.md)]
183222

184223
```bash
185-
az ml model create --file my_model.yml
224+
az ml datastore create --file my_datastore.yml
186225
```
187226

188-
For more information, see [model YAML schema](reference-yaml-model.md).
227+
For the content of the file, see [datastore YAML examples](https://github.com/Azure/azureml-examples/tree/main/cli/resources/datastore).
189228

229+
### [Studio](#tab/azure-studio)
190230

191-
### [Python SDK](#tab/sdk)
231+
1. Select a workspace if you are not already in one.
232+
1. From the left-hand menu, select **Data**.
233+
1. On the top, select **Datastores**.
234+
1. Select **Create** to create a new datastore.
192235

193-
To create a model using Python SDK v2, you can use the following code:
236+
---
194237

195-
[!INCLUDE [sdk v2](includes/machine-learning-sdk-v2.md)]
238+
## Model
196239

197-
```python
198-
my_model = Model(
199-
path="model.pkl", # the path to where my model file is located
200-
type="custom_model", # can be custom_model, mlflow_model or triton_model
201-
name="my-model",
202-
description="Model created from local file.",
203-
)
240+
Azure Machine Learning models consist of the binary file(s) that represent a machine learning model and any corresponding metadata. Models can be created from a local or remote file or directory. For remote locations `https`, `wasbs` and `azureml` locations are supported. The created model will be tracked in the workspace under the specified name and version. Azure Machine Learning supports three types of storage format for models:
204241

205-
ml_client.models.create_or_update(my_model) # use the MLClient to connect to workspace and create/register the model
206-
```
242+
* `custom_model`
243+
* `mlflow_model`
244+
* `triton_model`
207245

208-
---
246+
### Create a model in the model registry
247+
248+
Model registration allows you to store and version your models in the Azure cloud, in your workspace. The model registry helps you organize and keep track of your trained models.
249+
250+
For more information on how to create models in the registry, see [Work with models in Azure Machine Learning](how-to-manage-models.md).
209251

210252
## Environment
211253

@@ -225,36 +267,25 @@ In custom environments, you're responsible for setting up your environment and i
225267

226268
### Create an Azure Machine Learning custom environment
227269

228-
### [Azure CLI](#tab/cli)
229-
230-
To create an environment using CLI v2, use the following command:
231-
232-
[!INCLUDE [cli v2](includes/machine-learning-cli-v2.md)]
233-
234-
```bash
235-
az ml environment create --file my_environment.yml
236-
```
237-
For more information, see [environment YAML schema](reference-yaml-environment.md).
238270

271+
### [Python SDK](#tab/sdk)
239272

273+
To create an environment using Python SDK v2, see [Create an environment](how-to-manage-environments-v2.md?tabs=python#create-an-environment).
240274

241-
### [Python SDK](#tab/sdk)
275+
This [Jupyter notebook](https://github.com/Azure/azureml-examples/blob/main/sdk/python/assets/environment/environment.ipynb) shows more ways to create custom environments using SDK v2.
242276

243-
To create an environment using Python SDK v2, you can use the following code:
277+
### [Azure CLI](#tab/cli)
244278

245-
[!INCLUDE [sdk v2](includes/machine-learning-sdk-v2.md)]
279+
To create an environment using CLI v2, see [Create an environment](how-to-manage-environments-v2.md?tabs=cli#create-an-environment).
246280

247-
```python
248-
my_env = Environment(
249-
image="pytorch/pytorch:latest", # base image to use
250-
name="docker-image-example", # name of the model
251-
description="Environment created from a Docker image.",
252-
)
281+
For more information, see [environment YAML schema](reference-yaml-environment.md).
253282

254-
ml_client.environments.create_or_update(my_env) # use the MLClient to connect to workspace and create/register the environment
255-
```
283+
### [Studio](#tab/azure-studio)
256284

257-
This [Jupyter notebook](https://github.com/Azure/azureml-examples/blob/main/sdk/python/assets/environment/environment.ipynb) shows more ways to create custom environments using SDK v2.
285+
1. Select a workspace if you are not already in one.
286+
1. From the left-hand menu, select **Environments**.
287+
1. On the top, select **Custom environments**.
288+
1. Select **Create** to create a new custom environment.
258289

259290
---
260291

0 commit comments

Comments
 (0)