You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note that `--depth 1` clones only the latest commit to the repository, which reduces time to complete the operation.
47
47
48
+
### Connect to the workspace
49
+
50
+
> [!TIP]
51
+
> Use the tabs below to select the method you want to use to work with environments. Selecting a tab will automatically switch all the tabs in this article to the same tab. You can select another tab at any time.
52
+
53
+
# [Azure CLI](#tab/cli)
54
+
55
+
When using the Azure CLI, you need identifier parameters - a subscription, resource group, and workspace name. While you can specify these parameters for each command, you can also set defaults that will be used for all the commands. Use the following commands to set default values. Replace `<subscription ID>`, `<AzureML workspace name>`, and `<resource group>` with the values for your configuration:
56
+
57
+
```azurecli
58
+
az account set --subscription <subscription ID>
59
+
az configure --defaults workspace=<AzureML workspace name> group=<resource group>
60
+
```
61
+
62
+
# [Python SDK](#tab/python)
63
+
64
+
To connect to the workspace, you need identifier parameters - a subscription, resource group, and workspace name. You'll use these details in the `MLClient` from the `azure.ai.ml` namespace to get a handle to the required Azure Machine Learning workspace. To authenticate, you use the [default Azure authentication](/python/api/azure-identity/azure.identity.defaultazurecredential?view=azure-python&preserve-view=true). Check this [example](https://github.com/Azure/azureml-examples/blob/v2samplesreorg/sdk/python/jobs/configuration.ipynb) for more details on how to configure credentials and connect to a workspace.
65
+
66
+
```python
67
+
#import required libraries for workspace
68
+
from azure.ai.ml import MLClient
69
+
from azure.identity import DefaultAzureCredential
70
+
71
+
#import required libraries for environments examples
72
+
from azure.ai.ml.entities import Environment, BuildContext
There are two types of environments in Azure ML: curated and custom environments. Curated environments are predefined environments containing popular ML frameworks and tooling. Custom environments are user-defined and can be created via `az ml environment create`.
@@ -57,15 +94,7 @@ You can see the set of available curated environments in the Azure ML studio UI,
57
94
58
95
## Create an environment
59
96
60
-
You can define an environment from a conda specification, Docker image, or Docker build context.
61
-
62
-
The Azure CLI allows you to define the environment using a YAML specification file and create the environment using the following CLI command:
63
-
64
-
```cli
65
-
az ml environment create --file my_environment.yml
66
-
```
67
-
68
-
For the YAML reference documentation for Azure ML environments, see [CLI (v2) environment YAML schema](reference-yaml-environment.md).
97
+
You can define an environment from a Docker image, a Docker build context, and a conda specification with Docker image.
69
98
70
99
### Create an environment from a Docker image
71
100
@@ -83,7 +112,7 @@ To create the environment:
83
112
az ml environment create --file assets/environment/docker-image.yml
84
113
```
85
114
86
-
# [Python SDK](#tab/sdk)
115
+
# [Python SDK](#tab/python)
87
116
88
117
The following example creates an environment from a Docker image. An image from the official PyTorch repository on Docker Hub is specified via the `image` property.
89
118
@@ -121,7 +150,7 @@ To create the environment:
121
150
az ml environment create --file assets/environment/docker-context.yml
122
151
```
123
152
124
-
# [Python SDK](#tab/sdk)
153
+
# [Python SDK](#tab/python)
125
154
126
155
In the following example, the local path to the build context folder is specified in the `path' parameter. Azure ML will look for a Dockerfile named `Dockerfile` at the root of the build context.
127
156
@@ -156,7 +185,7 @@ To create the environment:
156
185
az ml environment create --file assets/environment/docker-image-plus-conda.yml
157
186
```
158
187
159
-
## [Python SDK](#tab/sdk)
188
+
## [Python SDK](#tab/python)
160
189
161
190
The relative path to the conda file is specified using the `conda_file` parameter.
162
191
@@ -188,7 +217,7 @@ List all the environments in your workspace:
188
217
az ml environment list
189
218
```
190
219
191
-
# [Python SDK](#tab/sdk)
220
+
# [Python SDK](#tab/python)
192
221
193
222
```python
194
223
envs = ml_client.environments.list()
@@ -206,7 +235,7 @@ List all the environment versions under a given name:
206
235
az ml environment list --name docker-image-example
> For environments, only `description` and `tags` can be updated. All other properties are immutable; if you need to change any of those properties you should create a new version of the environment.
257
286
258
-
### Archive and restore
287
+
### Archive
259
288
260
-
Archiving an environment will hide it by default from list queries (`az ml environment list`). You can still continue to reference and use an archived environment in your workflows. You can archive either an environment container or a specific environment version.
289
+
Archiving an environment will hide it by default from list queries (`az ml environment list`). You can still continue to reference and use an archived environment in your workflows. You can archive either all versions of an environment or only a specific version.
261
290
262
-
Archiving an environment container will archive all versions of the environment under that given name. If you create a new environment version under an archived environment container, that new version will automatically be set as archived as well.
291
+
If you don't specify a version, all versions of the environment under that given name will be archived. If you create a new environment version under an archived environment container, that new version will automatically be set as archived as well.
263
292
264
-
Archive an environment container:
293
+
Archive all versions of an environment:
265
294
266
295
# [Azure CLI](#tab/cli)
267
296
268
297
```cli
269
298
az ml environment archive --name docker-image-example
You can restore an archived environment to no longer hide it from list queries.
297
326
298
-
If an entire environment container is archived, you can restore that archived container. You can't restore only a specific environment version if the entire environment container is archived - you'll need to restore the entire container.
327
+
If you archived all versions of an environment, you can't restore only a specific version - you'll need to restore all versions.
299
328
300
-
Restore an environment container:
329
+
Restore all environment versions:
301
330
302
331
# [Azure CLI](#tab/cli)
303
332
304
333
```cli
305
334
az ml environment restore --name docker-image-example
To use an environment for a training job, specify the `environment` field of the job YAML configuration. You can either reference an existing registered Azure ML environment via `environment: azureml:<environment-name>:<environment-version>` or `environment: azureml:<environment-name>@latest` (to reference the latest version of an environment), or define an environment specification inline. If defining an environment inline, don't specify the `name` and `version` fields, as these environments are treated as "unregistered" environments and aren't tracked in your environment asset registry.
339
368
340
-
# [Python SDK](#tab/sdk)
369
+
# [Python SDK](#tab/python)
341
370
342
371
To use an environment for a training job, specify the `environment` property of the [command](/python/api/azure-ai-ml/azure.ai.ml#azure-ai-ml-command).
343
372
@@ -358,7 +387,7 @@ You can also use environments for your model deployments for both online and bat
358
387
359
388
For more information on how to use environments in deployments, see [Deploy and score a machine learning model by using a managed online endpoint](how-to-deploy-managed-online-endpoints.md).
360
389
361
-
# [Python SDK](#tab/sdk)
390
+
# [Python SDK](#tab/python)
362
391
363
392
You can also use environments for your model deployments. For more information, see [Deploy and score a machine learning model](how-to-deploy-managed-online-endpoint-sdk-v2.md).
0 commit comments