Skip to content

Commit 88b3566

Browse files
Merge pull request #228282 from jhirono/jhirono-patch-1
Update how-to-secure-training-vnet.md
2 parents 7dab5f8 + 6eabf53 commit 88b3566

File tree

1 file changed

+24
-30
lines changed

1 file changed

+24
-30
lines changed

articles/machine-learning/how-to-secure-training-vnet.md

Lines changed: 24 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -165,20 +165,18 @@ az ml compute create --name myci --resource-group rg --workspace-name ws --vnet-
165165
> The following code snippet assumes that `ml_client` points to an Azure Machine Learning workspace that uses a private endpoint to participate in a VNet. For more information on using `ml_client`, see the tutorial [Azure Machine Learning in a day](tutorial-azure-ml-in-a-day.md).
166166
167167
```python
168-
from azure.ai.ml.entities import AmlCompute
169-
170-
# specify aml compute name.
171-
cpu_compute_target = "cpu-cluster"
172-
173-
try:
174-
ml_client.compute.get(cpu_compute_target)
175-
except Exception:
176-
print("Creating a new cpu compute target...")
177-
compute = AmlCompute(
178-
name=cpu_compute_target, size="STANDARD_D2_V2", min_instances=0, max_instances=4,
179-
vnet_name="yourvnet", subnet_name="yoursubnet", enable_node_public_ip=False
180-
)
181-
ml_client.compute.begin_create_or_update(compute).result()
168+
from azure.ai.ml.entities import AmlCompute, NetworkSettings
169+
170+
network_settings = NetworkSettings(vnet_name="<vnet-name>", subnet="<subnet-name>")
171+
compute = AmlCompute(
172+
name=cpu_compute_target,
173+
size="STANDARD_D2_V2",
174+
min_instances=0,
175+
max_instances=4,
176+
enable_node_public_ip=False,
177+
network_settings=network_settings
178+
)
179+
ml_client.begin_create_or_update(entity=compute)
182180
```
183181

184182
# [Studio](#tab/azure-studio)
@@ -268,21 +266,17 @@ az ml compute create --name myci --resource-group rg --workspace-name ws --vnet-
268266
> The following code snippet assumes that `ml_client` points to an Azure Machine Learning workspace that uses a private endpoint to participate in a VNet. For more information on using `ml_client`, see the tutorial [Azure Machine Learning in a day](tutorial-azure-ml-in-a-day.md).
269267
270268
```python
271-
from azure.ai.ml.entities import AmlCompute
272-
273-
# specify aml compute name.
274-
cpu_compute_target = "cpu-cluster"
275-
276-
try:
277-
ml_client.compute.get(cpu_compute_target)
278-
except Exception:
279-
print("Creating a new cpu compute target...")
280-
# Replace "yourvnet" and "yoursubnet" with your VNet and subnet.
281-
compute = AmlCompute(
282-
name=cpu_compute_target, size="STANDARD_D2_V2", min_instances=0, max_instances=4,
283-
vnet_name="yourvnet", subnet_name="yoursubnet"
284-
)
285-
ml_client.compute.begin_create_or_update(compute).result()
269+
from azure.ai.ml.entities import AmlCompute, NetworkSettings
270+
271+
network_settings = NetworkSettings(vnet_name="<vnet-name>", subnet="<subnet-name>")
272+
compute = AmlCompute(
273+
name=cpu_compute_target,
274+
size="STANDARD_D2_V2",
275+
min_instances=0,
276+
max_instances=4,
277+
network_settings=network_settings
278+
)
279+
ml_client.begin_create_or_update(entity=compute)
286280
```
287281

288282
# [Studio](#tab/azure-studio)
@@ -365,4 +359,4 @@ This article is part of a series on securing an Azure Machine Learning workflow.
365359
* [Secure the inference environment](how-to-secure-inferencing-vnet.md)
366360
* [Enable studio functionality](how-to-enable-studio-virtual-network.md)
367361
* [Use custom DNS](how-to-custom-dns.md)
368-
* [Use a firewall](how-to-access-azureml-behind-firewall.md)
362+
* [Use a firewall](how-to-access-azureml-behind-firewall.md)

0 commit comments

Comments
 (0)