AksCompute Class

Manages an Azure Kubernetes Service compute target in Azure Machine Learning.

Azure Kubernetes Service (AKSCompute) targets are typically used for high-scale production deployments because they provides fast response time and autoscaling of the deployed service. For more information, see What are compute targets in Azure Machine Learning?

Class ComputeTarget constructor.

Retrieve a cloud representation of a Compute object associated with the provided workspace. Returns an instance of a child class corresponding to the specific type of the retrieved Compute object.

Inheritance
AksCompute

Constructor

AksCompute(workspace, name)

Parameters

Name Description
workspace
Required

The workspace object containing the AksCompute object to retrieve.

name
Required
str

The name of the AksCompute object to retrieve.

workspace
Required

The workspace object containing the Compute object to retrieve.

name
Required
str

The name of the of the Compute object to retrieve.

Remarks

The following sample shows how to create an AKS cluster with FPGA-enabled machines.


   from azureml.core.compute import AksCompute, ComputeTarget

   # Uses the specific FPGA enabled VM (sku: Standard_PB6s)
   # Standard_PB6s are available in: eastus, westus2, westeurope, southeastasia
   prov_config = AksCompute.provisioning_configuration(vm_size = "Standard_PB6s",
                                                       agent_count = 1,
                                                       location = "eastus")

   aks_name = 'my-aks-pb6'
   # Create the cluster
   aks_target = ComputeTarget.create(workspace = ws,
                                     name = aks_name,
                                     provisioning_configuration = prov_config)

Methods

attach

DEPRECATED. Use the attach_configuration method instead.

Associate an existing AKS compute resource with the provided workspace.

attach_configuration

Create a configuration object for attaching a AKS compute target.

delete

Remove the AksCompute object from its associated workspace.

If this object was created through Azure Machine Learning, the corresponding cloud-based objects will also be deleted. If this object was created externally and only attached to the workspace, this method raises a ComputeTargetException and nothing is changed.

deserialize

Convert a JSON object into an AksCompute object.

detach

Detach the AksCompute object from its associated workspace.

Underlying cloud objects are not deleted, only the association is removed.

get_credentials

Retrieve the credentials for the AKS target.

provisioning_configuration

Create a configuration object for provisioning an AKS compute target.

refresh_state

Perform an in-place update of the properties of the object.

This method updates the properties based on the current state of the corresponding cloud object. This is primarily used for manual polling of compute state.

serialize

Convert this AksCompute object into a json serialized dictionary.

update

Update the AksCompute object using the update configuration provided.

attach

DEPRECATED. Use the attach_configuration method instead.

Associate an existing AKS compute resource with the provided workspace.

static attach(workspace, name, resource_id)

Parameters

Name Description
workspace
Required

The workspace object to associate the compute resource with.

name
Required
str

The name to associate with the compute resource inside the provided workspace. Does not have to match the name of the compute resource to be attached.

resource_id
Required
str

The Azure resource ID for the compute resource being attached.

Returns

Type Description

An AksCompute object representation of the compute object.

Exceptions

Type Description

attach_configuration

Create a configuration object for attaching a AKS compute target.

static attach_configuration(resource_group=None, cluster_name=None, resource_id=None, cluster_purpose=None, load_balancer_type=None, load_balancer_subnet=None)

Parameters

Name Description
resource_group
str

The name of the resource group in which the AKS is located.

default value: None
cluster_name
str

The AKS cluster name.

default value: None
resource_id
str

The Azure resource ID for the compute resource being attached.

default value: None
cluster_purpose
str

The targeted usage of the cluster. This is used to provision Azure Machine Learning components to ensure the desired level of fault-tolerance and QoS. The ClusterPurpose class defines the possible values. For more information, see Attach an existing AKS cluster.

default value: None
load_balancer_type
str

The AKS cluster type. Valid values are PublicIp and InternalLoadBalancer. Default value is PublicIp.

default value: None
load_balancer_subnet
str

The AKS load balancer subnet. It can be used only when InternalLoadBalancer is used as load balancer type. Default value is aks-subnet.

default value: None

Returns

Type Description

A configuration object to be used when attaching a Compute object.

Exceptions

Type Description

delete

Remove the AksCompute object from its associated workspace.

If this object was created through Azure Machine Learning, the corresponding cloud-based objects will also be deleted. If this object was created externally and only attached to the workspace, this method raises a ComputeTargetException and nothing is changed.

delete()

Exceptions

Type Description

deserialize

Convert a JSON object into an AksCompute object.

static deserialize(workspace, object_dict)

Parameters

Name Description
workspace
Required

The workspace object the AksCompute object is associated with.

object_dict
Required

A JSON object to convert to an AksCompute object.

Returns

Type Description

The AksCompute representation of the provided JSON object.

Exceptions

Type Description

Remarks

Raises a ComputeTargetException if the provided workspace is not the workspace the Compute is associated with.

detach

Detach the AksCompute object from its associated workspace.

Underlying cloud objects are not deleted, only the association is removed.

detach()

Exceptions

Type Description

get_credentials

Retrieve the credentials for the AKS target.

get_credentials()

Returns

Type Description

The credentials for the AKS target.

Exceptions

Type Description

provisioning_configuration

Create a configuration object for provisioning an AKS compute target.

static provisioning_configuration(agent_count=None, vm_size=None, ssl_cname=None, ssl_cert_pem_file=None, ssl_key_pem_file=None, location=None, vnet_resourcegroup_name=None, vnet_name=None, subnet_name=None, service_cidr=None, dns_service_ip=None, docker_bridge_cidr=None, cluster_purpose=None, load_balancer_type=None, load_balancer_subnet=None)

Parameters

Name Description
agent_count
int

The number of agents (VMs) to host containers. Defaults to 3.

default value: None
vm_size
str

The size of agent VMs. A full list of options can be found here: https://aka.ms/azureml-aks-details. Defaults to Standard_D3_v2.

default value: None
ssl_cname
str

A CName to use if enabling SSL validation on the cluster. Must provide all three CName, cert file, and key file to enable SSL validation.

default value: None
ssl_cert_pem_file
str

A file path to a file containing cert information for SSL validation. Must provide all three CName, cert file, and key file to enable SSL validation.

default value: None
ssl_key_pem_file
str

A file path to a file containing key information for SSL validation. Must provide all three CName, cert file, and key file to enable SSL validation.

default value: None
location
str

The location to provision cluster in. If not specified, will default to workspace location. Available regions for this compute can be found here: https://azure.microsoft.com/global-infrastructure/services/?regions=all&products=kubernetes-service

default value: None
vnet_resourcegroup_name
str

The name of the resource group where the virtual network is located.

default value: None
vnet_name
str

The name of the virtual network.

default value: None
subnet_name
str

The name of the subnet inside the vnet.

default value: None
service_cidr
str

A CIDR notation IP range from which to assign service cluster IPs.

default value: None
dns_service_ip
str

Containers DNS server IP address.

default value: None
docker_bridge_cidr
str

A CIDR notation IP for Docker bridge.

default value: None
cluster_purpose
str

Targeted usage of the cluster. This is used to provision Azure Machine Learning components to ensure the desired level of fault-tolerance and QoS. AksCompute.ClusterPurpose class is provided for convenience of specifying available values. More detailed information of these values and their use cases can be found here: https://aka.ms/azureml-create-attach-aks

default value: None
load_balancer_type
str

Load balancer type of AKS cluster. Valid values are PublicIp and InternalLoadBalancer. Default value is PublicIp.

default value: None
load_balancer_subnet
str

Load balancer subnet of AKS cluster. It can be used only when Internal Load Balancer is used as load balancer type. Default value is aks-subnet.

default value: None

Returns

Type Description

A configuration object to be used when creating a Compute object

Exceptions

Type Description

refresh_state

Perform an in-place update of the properties of the object.

This method updates the properties based on the current state of the corresponding cloud object. This is primarily used for manual polling of compute state.

refresh_state()

Exceptions

Type Description

serialize

Convert this AksCompute object into a json serialized dictionary.

serialize()

Returns

Type Description

The JSON representation of this AksCompute object.

Exceptions

Type Description

update

Update the AksCompute object using the update configuration provided.

update(update_configuration)

Parameters

Name Description
update_configuration
Required

An AKS update configuration object.

Exceptions

Type Description