Skip to content

Commit ed79443

Browse files
authored
Merge pull request #100092 from Blackmist/vnet-private-ip
Updates for private IP
2 parents bd12f6d + 622f878 commit ed79443

File tree

1 file changed

+90
-14
lines changed

1 file changed

+90
-14
lines changed

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

Lines changed: 90 additions & 14 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,7 +40,7 @@ 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

4545
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.
4646

@@ -54,7 +54,7 @@ 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

@@ -85,7 +85,8 @@ 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:
89+
8990
1. Go to the key vault that's associated with the workspace.
9091

9192
[![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 +95,7 @@ To use Azure Machine Learning experimentation capabilities with Azure Key Vault
9495

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

97-
1. On the __Firewalls and virtual networks__ page, do the following:
98+
1. On the __Firewalls and virtual networks__ page, do the following actions:
9899
- Under __Allow access from__, select __Selected networks__.
99100
- Under __Virtual networks__, select __Add existing virtual networks__ to add the virtual network where your experimentation compute resides.
100101
- Under __Allow trusted Microsoft services to bypass this firewall__, select __Yes__.
@@ -155,11 +156,11 @@ The NSG rule configuration in the Azure portal is shown in the following images:
155156

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

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:
159+
If you don't want to use the default outbound rules and you do want to limit the outbound access of your virtual network, use the following steps:
159160

160161
- Deny outbound internet connection by using the NSG rules.
161162

162-
- Limit outbound traffic to the following:
163+
- Limit outbound traffic to the following items:
163164
- Azure Storage, by using __Service Tag__ of __Storage.Region_Name__ (for example, Storage.EastUS)
164165
- Azure Container Registry, by using __Service Tag__ of __AzureContainerRegistry.Region_Name__ (for example, AzureContainerRegistry.EastUS)
165166
- Azure Machine Learning, by using __Service Tag__ of __AzureMachineLearning__
@@ -220,13 +221,13 @@ For more information, see [Create an Azure Batch pool in a virtual network](../b
220221
221222
### Create a compute cluster in a virtual network
222223
223-
To create a Machine Learning Compute cluster, do the following:
224+
To create a Machine Learning Compute cluster, use the following steps:
224225
225226
1. In the [Azure portal](https://portal.azure.com), select your Azure Machine Learning workspace.
226227
227228
1. In the __Application__ section, select __Compute__, and then select __Add compute__.
228229
229-
1. To configure this compute resource to use a virtual network, do the following:
230+
1. To configure this compute resource to use a virtual network, do the following actions:
230231
231232
a. For __Network configuration__, select __Advanced__.
232233
@@ -294,14 +295,14 @@ For specific information on using Azure Databricks with a virtual network, see [
294295
> [!IMPORTANT]
295296
> Azure Machine Learning supports only virtual machines that are running Ubuntu.
296297
297-
To use a virtual machine or Azure HDInsight cluster in a virtual network with your workspace, do the following:
298+
To use a virtual machine or Azure HDInsight cluster in a virtual network with your workspace, use the following steps:
298299
299300
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:
300301
* [Create and manage Azure virtual networks for Linux VMs](https://docs.microsoft.com/azure/virtual-machines/linux/tutorial-virtual-network)
301302
302303
* [Extend HDInsight using an Azure virtual network](https://docs.microsoft.com/azure/hdinsight/hdinsight-extend-hadoop-virtual-network)
303304
304-
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:
305+
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:
305306
306307
* In the __Source__ drop-down list, select __Service Tag__.
307308
@@ -329,7 +330,7 @@ To use a virtual machine or Azure HDInsight cluster in a virtual network with yo
329330
330331
## Use Azure Kubernetes Service (AKS)
331332
332-
To add AKS in a virtual network to your workspace, do the following:
333+
To add AKS in a virtual network to your workspace, use the following steps:
333334
334335
> [!IMPORTANT]
335336
> 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.
@@ -344,7 +345,7 @@ To add AKS in a virtual network to your workspace, do the following:
344345
345346
1. In the __Application__ section, select __Compute__, and then select __Add compute__.
346347
347-
1. To configure this compute resource to use a virtual network, do the following:
348+
1. To configure this compute resource to use a virtual network, do the following actions:
348349
349350
- For __Network configuration__, select __Advanced__.
350351
@@ -390,6 +391,82 @@ aks_target = ComputeTarget.create(workspace=ws,
390391
391392
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).
392393
394+
### Use private IPs with Azure Kubernetes Service
395+
396+
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.
397+
398+
A private IP address is enabled by configuring AKS to use an _internal load balancer_.
399+
400+
> [!IMPORTANT]
401+
> You cannot enable private IP when creating the Azure Kubernetes Service cluster. It must be enabled as an update to an existing cluster.
402+
403+
The following code snippet demonstrates how to **create a new AKS cluster**, and then update it to use a private IP/internal load balancer:
404+
405+
```python
406+
import azureml.core
407+
from azureml.core.compute.aks import AksUpdateConfiguration
408+
from azureml.core.compute import AksCompute, ComputeTarget
409+
410+
# Verify that cluster does not exist already
411+
try:
412+
aks_target = AksCompute(workspace=ws, name=aks_cluster_name)
413+
print("Found existing aks cluster")
414+
415+
except:
416+
print("Creating new aks cluster")
417+
418+
# Create AKS configuration
419+
prov_config = AksCompute.provisioning_configuration(location = "eastus2")
420+
# Set info for existing virtual network to create the cluster in
421+
prov_config.vnet_resourcegroup_name = "myvnetresourcegroup"
422+
prov_config.vnet_name = "myvnetname"
423+
prov_config.service_cidr = "10.0.0.0/16"
424+
prov_config.dns_service_ip = "10.0.0.10"
425+
prov_config.subnet_name = "default"
426+
prov_config.docker_bridge_cidr = "172.17.0.1/16"
427+
428+
# Create compute target
429+
aks_target = ComputeTarget.create(workspace = ws, name = “myaks”, provisioning_configuration = prov_config)
430+
# Wait for the operation to complete
431+
aks_target.wait_for_completion(show_output = True)
432+
433+
# Update AKS configuration to use an internal load balancer
434+
update_config = AksUpdateConfiguration(None, "InternalLoadBalancer", "default")
435+
aks_target.update(update_config)
436+
# Wait for the operation to complete
437+
aks_target.wait_for_completion(show_output = True)
438+
```
439+
440+
__Azure CLI__
441+
442+
```azurecli-interactive
443+
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
444+
```
445+
446+
The contents of the `body.json` file referenced by the command are similar to the following JSON document:
447+
448+
```json
449+
{
450+
"location": “<region>”,
451+
"properties": {
452+
"resourceId": "/subscriptions/<subscription-id>/resourcegroups/<resource-group>/providers/Microsoft.ContainerService/managedClusters/<aks-resource-id>",
453+
"computeType": "AKS",
454+
"provisioningState": "Succeeded",
455+
"properties": {
456+
"loadBalancerType": "InternalLoadBalancer",
457+
"agentCount": <agent-count>,
458+
"agentVmSize": "vm-size",
459+
"clusterFqdn": "<cluster-fqdn>"
460+
}
461+
}
462+
}
463+
```
464+
465+
> [!NOTE]
466+
> 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.
467+
468+
For more information on using the internal load balancer with AKS, see [Use internal load balancer with Azure Kubernetes Service](/azure/aks/internal-lb).
469+
393470
## Use Azure Firewall
394471
395472
When using Azure Firewall, you must configure a network rule to allow traffic to and from the following addresses:
@@ -411,4 +488,3 @@ For more information on configuring a network rule, see [Deploy and configure Az
411488
* [Set up training environments](how-to-set-up-training-targets.md)
412489
* [Where to deploy models](how-to-deploy-and-where.md)
413490
* [Securely deploy models with SSL](how-to-secure-web-service.md)
414-

0 commit comments

Comments
 (0)