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
Copy file name to clipboardExpand all lines: articles/machine-learning/how-to-managed-network.md
+56-36Lines changed: 56 additions & 36 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,6 +10,7 @@ ms.author: larryfr
10
10
author: Blackmist
11
11
ms.date: 02/27/2025
12
12
ms.topic: how-to
13
+
zone_pivot_groups: azureml-portal-cli-python
13
14
ms.custom:
14
15
- build-2023
15
16
- devx-track-azurecli
@@ -88,7 +89,7 @@ If you add the following services to the virtual network by using either a servi
88
89
89
90
Before following the steps in this article, make sure you have the following prerequisites:
90
91
91
-
# [Azure CLI](#tab/azure-cli)
92
+
::: zone pivot="cli"
92
93
93
94
* 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](https://azure.microsoft.com/free/).
94
95
@@ -114,7 +115,8 @@ Before following the steps in this article, make sure you have the following pre
114
115
115
116
* The Azure CLI examples in this article use `ws` to represent the name of the workspace, and `rg` to represent the name of the resource group. Change these values as needed when using the commands with your Azure subscription.
116
117
117
-
# [Python SDK](#tab/python)
118
+
::: zone-end
119
+
::: zone pivot="python-sdk"
118
120
119
121
* 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](https://azure.microsoft.com/free/).
120
122
@@ -158,7 +160,8 @@ Before following the steps in this article, make sure you have the following pre
* 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](https://azure.microsoft.com/free/).
164
167
@@ -171,7 +174,7 @@ Before following the steps in this article, make sure you have the following pre
To establish private endpoint connections in managed virtual networks using Azure Machine Learning, the workspace managed identity, whether system-assigned or user-assigned, must have permissions to approve the Private Endpoint connections on the target resources. After April 30th, 2025, permissions aren't automatically granted to the managed identity and must be assigned manually.
177
180
@@ -209,7 +212,7 @@ For creating Private Endpoint outbound rules to default workspace resources, the
209
212
> [!IMPORTANT]
210
213
> __If you plan to submit serverless Spark jobs__, you must manually start provisioning. For more information, see the [configure for serverless Spark jobs](#configure-for-serverless-spark-jobs) section.
211
214
212
-
# [Azure CLI](#tab/azure-cli)
215
+
::: zone pivot="cli"
213
216
214
217
To configure a managed virtual network that allows internet outbound communications, you can use either the `--managed-network allow_internet_outbound` parameter or a YAML configuration file that contains the following entries:
215
218
@@ -288,7 +291,8 @@ You can configure a managed virtual network using either the `az ml workspace cr
288
291
type: private_endpoint
289
292
```
290
293
291
-
# [Python SDK](#tab/python)
294
+
::: zone-end
295
+
::: zone pivot="python-sdk"
292
296
293
297
To configure a managed virtual network that allows internet outbound communications, use the `ManagedNetwork` class to define a network with `IsolationMode.ALLOW_INTERNET_OUTBOUND`. You can then use the `ManagedNetwork` object to create a new workspace or update an existing one. To define _outbound rules_ to Azure services that the workspace relies on, use the `PrivateEndpointDestination` class to define a new private endpoint to the service.
294
298
@@ -355,7 +359,8 @@ To configure a managed virtual network that allows internet outbound communicati
355
359
ml_client.workspaces.begin_update(ws)
356
360
```
357
361
358
-
# [Azure portal](#tab/portal)
362
+
::: zone-end
363
+
::: zone pivot="azure-portal"
359
364
360
365
* __Create a new workspace__:
361
366
@@ -401,7 +406,7 @@ To configure a managed virtual network that allows internet outbound communicati
401
406
402
407
1. Select __Save__ at the top of the page to save the changes to the managed virtual network.
403
408
404
-
---
409
+
::: zone-end
405
410
406
411
## Configure a managed virtual network to allow only approved outbound
407
412
@@ -411,7 +416,7 @@ To configure a managed virtual network that allows internet outbound communicati
411
416
> [!IMPORTANT]
412
417
> __If you plan to submit serverless Spark jobs__, you must manually start provisioning. For more information, see the [configure for serverless Spark jobs](#configure-for-serverless-spark-jobs) section.
413
418
414
-
# [Azure CLI](#tab/azure-cli)
419
+
::: zone pivot="cli"
415
420
416
421
To configure a managed virtual network that allows only approved outbound communications, you can use either the `--managed-network allow_only_approved_outbound` parameter or a YAML configuration file that contains the following entries:
417
422
@@ -512,7 +517,8 @@ You can configure a managed virtual network using either the `az ml workspace cr
512
517
type: private_endpoint
513
518
```
514
519
515
-
# [Python SDK](#tab/python)
520
+
::: zone-end
521
+
::: zone pivot="python-sdk"
516
522
517
523
To configure a managed virtual network that allows only approved outbound communications, use the `ManagedNetwork` class to define a network with `IsolationMode.ALLOw_ONLY_APPROVED_OUTBOUND`. You can then use the `ManagedNetwork` object to create a new workspace or update an existing one. To define _outbound rules_, use the following classes:
518
524
@@ -654,7 +660,8 @@ To configure a managed virtual network that allows only approved outbound commun
654
660
ml_client.workspaces.begin_update(ws)
655
661
```
656
662
657
-
# [Azure portal](#tab/portal)
663
+
::: zone-end
664
+
::: zone pivot="azure-portal"
658
665
659
666
* __Create a new workspace__:
660
667
@@ -721,7 +728,7 @@ To configure a managed virtual network that allows only approved outbound commun
721
728
722
729
1. Select __Save__ at the top of the page to save the changes to the managed virtual network.
723
730
724
-
---
731
+
::: zone-end
725
732
726
733
727
734
## Configure for serverless Spark jobs
@@ -736,7 +743,7 @@ To enable the [serverless Spark jobs](how-to-submit-spark-jobs.md) for the manag
736
743
737
744
1. Configure an outbound private endpoint.
738
745
739
-
# [Azure CLI](#tab/azure-cli)
746
+
::: zone pivot="cli"
740
747
741
748
Use a YAML file to define the managed virtual network configuration and add a private endpoint for the Azure Storage Account. Also set `spark_enabled: true`:
742
749
@@ -765,7 +772,8 @@ To enable the [serverless Spark jobs](how-to-submit-spark-jobs.md) for the manag
765
772
> [!NOTE]
766
773
> When **Allow Only Approved Outbound** is enabled (`isolation_mode: allow_only_approved_outbound`), conda package dependencies defined in Spark session configuration fails to install. To resolve this problem, upload a self-contained Python package wheel with no external dependencies to an Azure storage account and create private endpoint to this storage account. Use the path to Python package wheel as `py_files` parameter in your Spark job. Setting an FQDN outbound rule won't bypass this issue as FQDN rule propagation isn't supported by Spark.
767
774
768
-
# [Python SDK](#tab/python)
775
+
::: zone-end
776
+
::: zone pivot="python-sdk"
769
777
770
778
The following example demonstrates how to create a managed virtual network for an existing Azure Machine Learning workspace named `myworkspace`. It also adds a private endpoint for the Azure Storage Account and sets `spark_enabled=true`:
771
779
@@ -801,7 +809,8 @@ To enable the [serverless Spark jobs](how-to-submit-spark-jobs.md) for the manag
801
809
> - If the workspace was created with `IsolationMode.ALLOW_INTERNET_OUTBOUND`, it can’t be updated later to use `IsolationMode.ALLOW_ONLY_APPROVED_OUTBOUND`.
802
810
803
811
804
-
# [Azure portal](#tab/portal)
812
+
::: zone-end
813
+
::: zone pivot="azure-portal"
805
814
806
815
1. Sign in to the [Azure portal](https://portal.azure.com), and select the Azure Machine Learning workspace.
807
816
2. Select __Networking__, then select __Add user-defined outbound rules__. Add a rule for the Azure Storage Account, and make sure that __Spark enabled__ is selected.
@@ -810,22 +819,23 @@ To enable the [serverless Spark jobs](how-to-submit-spark-jobs.md) for the manag
810
819
811
820
3. Select __Save__ to save the rule, then select __Save__ from the top of __Networking__ to save the changes to the manged virtual network.
812
821
813
-
---
822
+
::: zone-end
814
823
815
824
2. Provision the managed virtual network.
816
825
817
826
> [!NOTE]
818
827
> If your workspace has [public network access enabled](/azure/machine-learning/how-to-configure-private-link#enable-public-access), you must disable it before provisioning the managed VNet. If you don't disable public network access when provisioning the managed VNet, the private endpoints for the workspace might not be created automatically in the managed VNet. Otherwise, you would have to manually configure the private endpoint outbound rule for the workspace after the provisioning.
819
828
820
-
# [Azure CLI](#tab/azure-cli)
829
+
::: zone pivot="cli"
821
830
822
831
The following example shows how to provision a managed virtual network for serverless Spark jobs by using the `--include-spark` parameter.
823
832
824
833
```azurecli
825
834
az ml workspace provision-network -g my_resource_group -n my_workspace_name --include-spark
826
835
```
827
836
828
-
# [Python SDK](#tab/python)
837
+
::: zone-end
838
+
::: zone pivot="python-sdk"
829
839
830
840
The following example shows how to provision a managed virtual network for serverless Spark jobs:
831
841
@@ -839,11 +849,12 @@ To enable the [serverless Spark jobs](how-to-submit-spark-jobs.md) for the manag
Use the __Azure CLI__ or __Python SDK__ tabs to learn how to manually provision the managed virtual network with serverless Spark support.
845
856
846
-
---
857
+
::: zone-end
847
858
848
859
## Manually provision a managed VNet
849
860
@@ -856,7 +867,7 @@ Alternatively, you can use the `provision_network_now` flag to provision the man
856
867
> [!NOTE]
857
868
> To create an online deployment, you must manually provision the managed network, or create a compute instance first which will automatically provision it.
858
869
859
-
# [Azure CLI](#tab/azure-cli)
870
+
::: zone pivot="cli"
860
871
861
872
The following example shows how to provision a managed virtual network during workspace creation.
862
873
@@ -879,7 +890,8 @@ To verify that the provisioning completed, use the following command:
879
890
az ml workspace show -n my_workspace_name -g my_resource_group --query managed_network
880
891
```
881
892
882
-
# [Python SDK](#tab/python)
893
+
::: zone-end
894
+
::: zone pivot="python-sdk"
883
895
884
896
To provision the managed network during workspace creation, set the `provision_network_now` flag to `True`.
During workspace creation, select __Provision managed network proactively at creation__ to provision the managed network. Charges are incurred from network resources, such as private endpoints, once the virtual network is provisioned. This configuration option is only available during workspace creation.
912
925
913
-
---
926
+
::: zone-end
914
927
915
928
## Configure image builds
916
929
@@ -919,15 +932,16 @@ When the Azure Container Registry for your workspace is behind a virtual network
919
932
> [!IMPORTANT]
920
933
> The compute resource used to build Docker images needs to be able to access the package repositories that are used to train and deploy your models. If you're using a network configured to allow only approved outbound, you might need to add [rules that allow access to public repos](#scenario-access-public-machine-learning-packages) or [use private Python packages](concept-vulnerability-management.md#using-a-private-package-repository).
921
934
922
-
# [Azure CLI](#tab/azure-cli)
935
+
::: zone pivot="cli"
923
936
924
937
To update a workspace to use a compute cluster or compute instance to build Docker images, use the `az ml workspace update` command with the `--image-build-compute` parameter:
925
938
926
939
```azurecli
927
940
az ml workspace update --name ws --resource-group rg --image-build-compute mycompute
928
941
```
929
942
930
-
# [Python SDK](#tab/python)
943
+
::: zone-end
944
+
::: zone pivot="python-sdk"
931
945
932
946
The following example demonstrates how to update a workspace to use a compute cluster to build images:
Currently there isn't a way to set the image build compute from the Azure portal. Use the __Azure CLI__ or __Python SDK__ tabs to learn how to manually configure image builds.
960
975
961
-
---
976
+
::: zone-end
962
977
963
978
## Manage outbound rules
964
979
965
-
# [Azure CLI](#tab/azure-cli)
980
+
::: zone pivot="cli"
966
981
967
982
To list the managed virtual network outbound rules for a workspace, use the following command:
968
983
@@ -982,7 +997,8 @@ To remove an outbound rule from the managed virtual network, use the following c
982
997
az ml workspace outbound-rule remove --rule rule-name --workspace-name ws --resource-group rg
983
998
```
984
999
985
-
# [Python SDK](#tab/python)
1000
+
::: zone-end
1001
+
::: zone pivot="python-sdk"
986
1002
987
1003
The following example demonstrates how to manage outbound rules for a workspace named `myworkspace`:
1. Sign in to the [Azure portal](https://portal.azure.com), and select the Azure Machine Learning workspace that you want to enable managed virtual network isolation for.
1009
1026
1. Select __Networking__. The __Workspace Outbound access__ section allows you to manage outbound rules.
* To __delete__ an outbound rule, select __delete__ for the rule.
1018
1035
1019
-
---
1036
+
::: zone-end
1020
1037
1021
1038
## List of required rules
1022
1039
@@ -1177,11 +1194,12 @@ An Azure Firewall is deployed if an FQDN outbound rule is created while in the _
1177
1194
1178
1195
Use the following tabs to learn how to select the firewall version for your managed virtual network.
1179
1196
1180
-
# [Azure portal](#tab/portal)
1197
+
::: zone pivot="azure-portal"
1181
1198
1182
1199
After selecting the allow only approved outbound mode, an option to select the Azure Firewall version (SKU) appears. Select __Standard__ to use the standard version or __Basic__ to use the basic version. Select __Save__ to save your configuration.
1183
1200
1184
-
# [Azure CLI](#tab/azure-cli)
1201
+
::: zone-end
1202
+
::: zone pivot="cli"
1185
1203
1186
1204
To configure the firewall version from the CLI, use a YAML file and specify the `firewall_sku`. The following example demonstrates a YAML file that sets the firewall SKU to `basic`:
1187
1205
@@ -1200,15 +1218,17 @@ managed_network:
1200
1218
tags: {}
1201
1219
```
1202
1220
1203
-
# [Python SDK](#tab/python)
1221
+
::: zone-end
1222
+
::: zone pivot="python-sdk"
1204
1223
1205
1224
To configure the firewall version from the Python SDK, set the `firewall_sku` property of the `ManagedNetwork` object. The following example demonstrates how to set the firewall SKU to `basic`:
0 commit comments