Skip to content

Commit dccffa1

Browse files
author
Larry Franks
committed
writing
1 parent 3b05ec9 commit dccffa1

File tree

1 file changed

+98
-29
lines changed

1 file changed

+98
-29
lines changed

articles/machine-learning/how-to-enable-virtual-network.md

Lines changed: 98 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ ms.topic: conceptual
1010
ms.reviewer: larryfr
1111
ms.author: aashishb
1212
author: aashishb
13-
ms.date: 11/13/2019
13+
ms.date: 01/03/2020
1414
---
1515

1616
# Secure Azure ML experimentation and inference jobs within an Azure Virtual Network
@@ -40,9 +40,9 @@ This article also provides detailed information about *advanced security setting
4040

4141
## Use a storage account for your workspace
4242

43-
To use an Azure storage account for the workspace in a virtual network, do the following:
43+
To use an Azure storage account for the workspace in a virtual network, use the following steps:
4444

45-
1. Create a compute resource (for example, a Machine Learning compute instance or cluster) behind a virtual network, or attach a compute resource to the workspace (for example, an HDInsight cluster, virtual machine, or Azure Kubernetes Service cluster). The compute resource can be for experimentation or model deployment.
45+
1. Create a compute resource (for example, a Machine Learning cluster) behind a virtual network, or attach a compute resource to the workspace (for example, an HDInsight cluster, virtual machine, or Azure Kubernetes Service cluster). The compute resource can be for experimentation or model deployment.
4646

4747
For more information, see the [Use a Machine Learning compute](#amlcompute), [Use a virtual machine or HDInsight cluster](#vmorhdi), and [Use Azure Kubernetes Service](#aksvnet) sections in this article.
4848

@@ -54,12 +54,12 @@ To use an Azure storage account for the workspace in a virtual network, do the f
5454

5555
![The "Firewalls and virtual networks" area on the Azure Storage page in the Azure portal](./media/how-to-enable-virtual-network/storage-firewalls-and-virtual-networks.png)
5656

57-
1. On the __Firewalls and virtual networks__ page, do the following:
57+
1. On the __Firewalls and virtual networks__ page, do the following actions:
5858
- Select __Selected networks__.
5959
- Under __Virtual networks__, select the __Add existing virtual network__ link. This action adds the virtual network where your compute resides (see step 1).
6060

6161
> [!IMPORTANT]
62-
> The storage account must be in the same virtual network as the compute instances or clusters used for training or inference.
62+
> The storage account must be in the same virtual network as the clusters used for training or inference.
6363
6464
- Select the __Allow trusted Microsoft services to access this storage account__ check box.
6565

@@ -85,7 +85,7 @@ The key vault instance that's associated with the workspace is used by Azure Mac
8585
* Passwords to Azure Container Repository instances
8686
* Connection strings to data stores
8787

88-
To use Azure Machine Learning experimentation capabilities with Azure Key Vault behind a virtual network, do the following:
88+
To use Azure Machine Learning experimentation capabilities with Azure Key Vault behind a virtual network, use the following steps:
8989
1. Go to the key vault that's associated with the workspace.
9090

9191
[![The key vault that's associated with the Azure Machine Learning workspace](./media/how-to-enable-virtual-network/workspace-key-vault.png)](./media/how-to-enable-virtual-network/workspace-key-vault.png#lightbox)
@@ -94,7 +94,7 @@ To use Azure Machine Learning experimentation capabilities with Azure Key Vault
9494

9595
![The "Firewalls and virtual networks" section in the Key Vault pane](./media/how-to-enable-virtual-network/key-vault-firewalls-and-virtual-networks.png)
9696

97-
1. On the __Firewalls and virtual networks__ page, do the following:
97+
1. On the __Firewalls and virtual networks__ page, do the following actions:
9898
- Under __Allow access from__, select __Selected networks__.
9999
- Under __Virtual networks__, select __Add existing virtual networks__ to add the virtual network where your experimentation compute resides.
100100
- Under __Allow trusted Microsoft services to bypass this firewall__, select __Yes__.
@@ -103,22 +103,18 @@ To use Azure Machine Learning experimentation capabilities with Azure Key Vault
103103

104104
<a id="amlcompute"></a>
105105

106-
## <a name="compute-instance"></a>Use a Machine Learning Compute
106+
## Use a Machine Learning Compute
107107

108-
> [!NOTE]
109-
> Compute instances (preview) are currently available only for workspaces with a region of **North Central US** or **UK South**, with support for other regions coming soon.
110-
> Use one of these regions to create a compute instance that can be added to virtual network.
111-
112-
To use an Azure Machine Learning compute instance or compute cluster in a virtual network, the following network requirements must be met:
108+
To use an Azure Machine Learning compute cluster in a virtual network, the following network requirements must be met:
113109

114110
> [!div class="checklist"]
115111
> * The virtual network must be in the same subscription and region as the Azure Machine Learning workspace.
116-
> * The subnet that's specified for the compute instance or cluster must have enough unassigned IP addresses to accommodate the number of VMs that are targeted. If the subnet doesn't have enough unassigned IP addresses, a compute cluster will be partially allocated.
112+
> * The subnet that's specified for the compute cluster must have enough unassigned IP addresses to accommodate the number of VMs that are targeted. If the subnet doesn't have enough unassigned IP addresses, a compute cluster will be partially allocated.
117113
> * Check to see whether your security policies or locks on the virtual network's subscription or resource group restrict permissions to manage the virtual network. If you plan to secure the virtual network by restricting traffic, leave some ports open for the compute service. For more information, see the [Required ports](#mlcports) section.
118-
> * If you're going to put multiple compute instances or clusters in one virtual network, you might need to request a quota increase for one or more of your resources.
119-
> * If the Azure Storage Account(s) for the workspace are also secured in a virtual network, they must be in the same virtual network as the Azure Machine Learning compute instance or cluster. If you are creating a compute instance in the same virtual network, you would need to detach the storage account(s) from the virtual network, create the compute instance in the virtual network, and then attach the storage account(s) back to the virtual network.
114+
> * If you're going to put multiple compute clusters in one virtual network, you might need to request a quota increase for one or more of your resources.
115+
> * If the Azure Storage Account(s) for the workspace are also secured in a virtual network, they must be in the same virtual network as the Azure Machine Learning compute cluster.
120116
121-
The Machine Learning compute instance or cluster automatically allocates additional networking resources in the resource group that contains the virtual network. For each compute instance or cluster, the service allocates the following resources:
117+
The Machine Learning compute cluster automatically allocates additional networking resources in the resource group that contains the virtual network. For each compute cluster, the service allocates the following resources:
122118

123119
* One network security group
124120
* One public IP address
@@ -141,8 +137,6 @@ Machine Learning Compute currently uses the Azure Batch service to provision VMs
141137

142138
- Outbound traffic on any port to the internet.
143139

144-
- For compute instance inbound TCP traffic on port 44224 from a __Service Tag__ of __AzureMachineLearning__.
145-
146140
Exercise caution if you modify or add inbound or outbound rules in Batch-configured NSGs. If an NSG blocks communication to the compute nodes, the compute service sets the state of the compute nodes to unusable.
147141

148142
You don't need to specify NSGs at the subnet level, because the Azure Batch service configures its own NSGs. However, if the specified subnet has associated NSGs or a firewall, configure the inbound and outbound security rules as mentioned earlier.
@@ -155,23 +149,22 @@ The NSG rule configuration in the Azure portal is shown in the following images:
155149

156150
### <a id="limiting-outbound-from-vnet"></a> Limit outbound connectivity from the virtual network
157151

158-
If you don't want to use the default outbound rules and you do want to limit the outbound access of your virtual network, do the following:
152+
If you don't want to use the default outbound rules and you do want to limit the outbound access of your virtual network, do the following actions:
159153

160154
- Deny outbound internet connection by using the NSG rules.
161155

162-
- Limit outbound traffic to the following:
156+
- Limit outbound traffic to the following resources:
163157
- Azure Storage, by using __Service Tag__ of __Storage.Region_Name__ (for example, Storage.EastUS)
164158
- Azure Container Registry, by using __Service Tag__ of __AzureContainerRegistry.Region_Name__ (for example, AzureContainerRegistry.EastUS)
165159
- Azure Machine Learning, by using __Service Tag__ of __AzureMachineLearning__
166-
- In case of compute instance, Azure Cloud, by using __Service Tag__ of __AzureCloud.Region_Name__ (for example, AzureCloud.NorthCentralUS)
167160

168161
The NSG rule configuration in the Azure portal is shown in the following image:
169162

170163
[![The outbound NSG rules for Machine Learning Compute](./media/how-to-enable-virtual-network/limited-outbound-nsg-exp.png)](./media/how-to-enable-virtual-network/limited-outbound-nsg-exp.png#lightbox)
171164

172165
### User-defined routes for forced tunneling
173166

174-
If you're using forced tunneling with the Machine Learning Compute, add [user-defined routes (UDRs)](https://docs.microsoft.com/azure/virtual-network/virtual-networks-udr-overview) to the subnet that contains the compute resource.
167+
If you're using forced tunneling with Machine Learning Compute, add [user-defined routes (UDRs)](https://docs.microsoft.com/azure/virtual-network/virtual-networks-udr-overview) to the subnet that contains the compute resource.
175168

176169
* Establish a UDR for each IP address that's used by the Azure Batch service in the region where your resources exist. These UDRs enable the Batch service to communicate with compute nodes for task scheduling. To get a list of IP addresses of the Batch service, use one of the following methods:
177170

@@ -193,13 +186,13 @@ For more information, see [Create an Azure Batch pool in a virtual network](../b
193186
194187
### Create a compute cluster in a virtual network
195188
196-
To create a Machine Learning Compute cluster, do the following:
189+
To create a Machine Learning Compute cluster, use the following steps:
197190
198191
1. In the [Azure portal](https://portal.azure.com), select your Azure Machine Learning workspace.
199192
200193
1. In the __Application__ section, select __Compute__, and then select __Add compute__.
201194
202-
1. To configure this compute resource to use a virtual network, do the following:
195+
1. To configure this compute resource to use a virtual network, do the following actions:
203196
204197
a. For __Network configuration__, select __Advanced__.
205198
@@ -267,14 +260,14 @@ For specific information on using Azure Databricks with a virtual network, see [
267260
> [!IMPORTANT]
268261
> Azure Machine Learning supports only virtual machines that are running Ubuntu.
269262
270-
To use a virtual machine or Azure HDInsight cluster in a virtual network with your workspace, do the following:
263+
To use a virtual machine or Azure HDInsight cluster in a virtual network with your workspace, use the following steps:
271264

272265
1. Create a VM or HDInsight cluster by using the Azure portal or the Azure CLI, and put the cluster in an Azure virtual network. For more information, see the following articles:
273266
* [Create and manage Azure virtual networks for Linux VMs](https://docs.microsoft.com/azure/virtual-machines/linux/tutorial-virtual-network)
274267

275268
* [Extend HDInsight using an Azure virtual network](https://docs.microsoft.com/azure/hdinsight/hdinsight-extend-hadoop-virtual-network)
276269

277-
1. To allow Azure Machine Learning to communicate with the SSH port on the VM or cluster, configure a source entry for the network security group. The SSH port is usually port 22. To allow traffic from this source, do the following:
270+
1. To allow Azure Machine Learning to communicate with the SSH port on the VM or cluster, configure a source entry for the network security group. The SSH port is usually port 22. To allow traffic from this source, do the following actions:
278271

279272
* In the __Source__ drop-down list, select __Service Tag__.
280273

@@ -302,7 +295,7 @@ To use a virtual machine or Azure HDInsight cluster in a virtual network with yo
302295

303296
## Use Azure Kubernetes Service (AKS)
304297

305-
To add AKS in a virtual network to your workspace, do the following:
298+
To add AKS in a virtual network to your workspace, use the following steps:
306299

307300
> [!IMPORTANT]
308301
> Before you begin the following procedure, follow the prerequisites in the [Configure advanced networking in Azure Kubernetes Service (AKS)](https://docs.microsoft.com/azure/aks/configure-advanced-networking#prerequisites) how-to and plan the IP addressing for your cluster.
@@ -317,7 +310,7 @@ To add AKS in a virtual network to your workspace, do the following:
317310

318311
1. In the __Application__ section, select __Compute__, and then select __Add compute__.
319312

320-
1. To configure this compute resource to use a virtual network, do the following:
313+
1. To configure this compute resource to use a virtual network, do the following actions:
321314

322315
- For __Network configuration__, select __Advanced__.
323316

@@ -363,6 +356,82 @@ aks_target = ComputeTarget.create(workspace=ws,
363356

364357
When the creation process is completed, you can run inference, or model scoring, on an AKS cluster behind a virtual network. For more information, see [How to deploy to AKS](how-to-deploy-and-where.md).
365358

359+
### Use private IPs with Azure Kubernetes Service
360+
361+
By default, a public IP address is assigned to AKS deployments. When using AKS inside a virtual network, you can use a private IP address instead. Private IP addresses are only accessible from inside the virtual network or joined networks.
362+
363+
A private IP address is enabled by configuring AKS to use an _internal load balancer_.
364+
365+
> [!IMPORTANT]
366+
> You cannot enable private IP when creating the Azure Kubernetes Service cluster. It must be enabled as an update to an existing cluster.
367+
368+
The following code snippet demonstrates how to **create a new AKS cluster**, and then update it to use a private IP/internal load balancer
369+
370+
```python
371+
import azureml.core
372+
from azureml.core.compute import AksCompute, ComputeTarget
373+
374+
# Verify that cluster does not exist already
375+
try:
376+
aks_target = AksCompute(workspace=ws, name=aks_cluster_name)
377+
print("Found existing aks cluster")
378+
379+
except:
380+
print("Creating new aks cluster")
381+
382+
# Create AKS configuration
383+
prov_config = AksCompute.provisioning_configuration(location = "eastus2")
384+
# Set info for existing virtual network to create the cluster in
385+
prov_config.vnet_resourcegroup_name = "myvnetresourcegroup"
386+
prov_config.vnet_name = "myvnetname"
387+
prov_config.service_cidr = "10.0.0.0/16"
388+
prov_config.dns_service_ip = "10.0.0.10"
389+
prov_config.subnet_name = "default"
390+
prov_config.docker_bridge_cidr = "172.17.0.1/16"
391+
392+
# Create compute target
393+
aks_target = ComputeTarget.create(workspace = ws, name = “myaks”, provisioning_configuration = prov_config)
394+
# Wait for the operation to complete
395+
aks_target.wait_for_completion(show_output = True)
396+
397+
# Update AKS configuration to use an internal load balancer
398+
update_config = AksUpdateConfiguration(None, "InternalLoadBalancer")
399+
aks_target.update(update_config)
400+
# Wait for the operation to complete
401+
aks_target.wait_for_completion(show_output = True)
402+
403+
```
404+
405+
__Azure CLI__
406+
407+
```azurecli-interactive
408+
az rest --method put --uri https://management.azure.com"/subscriptions/<subscription-id>/resourcegroups/<resource-group>/providers/Microsoft.ContainerService/managedClusters/<aks-resource-id>?api-version=2018-11-19 --body @body.json
409+
```
410+
411+
The contents of the `body.json` file referenced by the command are similar to the following JSON document:
412+
413+
```json
414+
{
415+
"location": “<region>”,
416+
"properties": {
417+
"resourceId": "/subscriptions/<subscription-id>/resourcegroups/<resource-group>/providers/Microsoft.ContainerService/managedClusters/<aks-resource-id>",
418+
"computeType": "AKS",
419+
"provisioningState": "Succeeded",
420+
"properties": {
421+
"loadBalancerType": "InternalLoadBalancer",
422+
"agentCount": <agent-count>,
423+
"agentVmSize": "vm-size",
424+
"clusterFqdn": "<cluster-fqdn>"
425+
}
426+
}
427+
}
428+
```
429+
430+
> [!NOTE]
431+
> Currently, you cannot configure the load balancer when performing an __attach__ operation on an existing cluster. You must first attach the cluster, and then perform an update operation to change the load balancer.
432+
433+
For more information on using the internal load balancer with AKS, see [Use internal load balancer with Azure Kubernetes Service](/azure/aks/internal-lb).
434+
366435
## Use Azure Firewall
367436

368437
When using Azure Firewall, you must configure a network rule to allow traffic to and from the following addresses:

0 commit comments

Comments
 (0)