Search code examples
azure-aksazure-machine-learning-service

Azure ML Kubernetes - Private IP


I have an AKS cluster in a VNET/Subnet. My AKS is linked to AzureML.

I successfully deployed an Azure ML service to that AKS.

However, I see that the azureml-fe service is responding to a public IP and not a private IP from my VNET/Subnet.

How can I make it so my AzureML inference service is exposed with a private IP?


Solution

  • Maybe you need to use an internal load balancer, then it will use a private IP address. Here is the example code for Python:

    from azureml.core.compute.aks import AksUpdateConfiguration
    from azureml.core.compute import AksCompute, ComputeTarget
    
    # When you create an AKS cluster, you can specify Internal Load Balancer to be created with provisioning_config object
    provisioning_config = AksCompute.provisioning_configuration(load_balancer_type = 'InternalLoadBalancer')
    
    # when you attach an AKS cluster, you can update the cluster to use internal load balancer after attach
    aks_target = AksCompute(ws,"myaks")
    
    # Change to the name of the subnet that contains AKS
    subnet_name = "default"
    # Update AKS configuration to use an internal load balancer
    update_config = AksUpdateConfiguration(None, "InternalLoadBalancer", subnet_name)
    aks_target.update(update_config)
    # Wait for the operation to complete
    aks_target.wait_for_completion(show_output = True)