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

workspace
Workspace
Required

The workspace object containing the AksCompute object to retrieve.

name
str
Required

The name of the AksCompute object to retrieve.

workspace
Workspace
Required

The workspace object containing the Compute object to retrieve.

name
str
Required

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

workspace
Workspace
Required

The workspace object to associate the compute resource with.

name
str
Required

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
str
Required

The Azure resource ID for the compute resource being attached.

Returns

An AksCompute object representation of the compute object.

Return type

Exceptions

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

resource_group
str
default value: None

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

cluster_name
str
default value: None

The AKS cluster name.

resource_id
str
default value: None

The Azure resource ID for the compute resource being attached.

cluster_purpose
str
default value: None

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.

load_balancer_type
str
default value: None

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

load_balancer_subnet
str
default value: None

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

Returns

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

Return type

Exceptions

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

deserialize

Convert a JSON object into an AksCompute object.

static deserialize(workspace, object_dict)

Parameters

workspace
Workspace
Required

The workspace object the AksCompute object is associated with.

object_dict
dict
Required

A JSON object to convert to an AksCompute object.

Returns

The AksCompute representation of the provided JSON object.

Return type

Exceptions

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

get_credentials

Retrieve the credentials for the AKS target.

get_credentials()

Returns

The credentials for the AKS target.

Return type

Exceptions

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

agent_count
int
default value: None

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

vm_size
str
default value: None

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.

ssl_cname
str
default value: None

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.

ssl_cert_pem_file
str
default value: None

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.

ssl_key_pem_file
str
default value: None

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.

location
str
default value: None

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

vnet_resourcegroup_name
str
default value: None

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

vnet_name
str
default value: None

The name of the virtual network.

subnet_name
str
default value: None

The name of the subnet inside the vnet.

service_cidr
str
default value: None

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

dns_service_ip
str
default value: None

Containers DNS server IP address.

docker_bridge_cidr
str
default value: None

A CIDR notation IP for Docker bridge.

cluster_purpose
str
default value: None

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

load_balancer_type
str
default value: None

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

load_balancer_subnet
str
default value: None

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.

Returns

A configuration object to be used when creating a Compute object

Return type

Exceptions

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

serialize

Convert this AksCompute object into a json serialized dictionary.

serialize()

Returns

The JSON representation of this AksCompute object.

Return type

Exceptions

update

Update the AksCompute object using the update configuration provided.

update(update_configuration)

Parameters

update_configuration
AksUpdateConfiguration
Required

An AKS update configuration object.

Exceptions