or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

agent-pools.mdindex.mdmachines.mdmaintenance.mdmanaged-clusters.mdmodels.mdprivate-endpoints.mdsnapshots.mdtrusted-access.md
tile.json

tessl/pypi-azure-mgmt-containerservice

Microsoft Azure Container Service Management Client Library for Python

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/azure-mgmt-containerservice@39.1.x

To install, run

npx @tessl/cli install tessl/pypi-azure-mgmt-containerservice@39.1.0

index.mddocs/

Azure Container Service Management Client

A comprehensive Python client library for managing Azure Kubernetes Service (AKS) resources through the Azure Resource Manager REST API. This library enables developers to programmatically create, configure, and manage Kubernetes clusters on Azure, including operations for cluster lifecycle management, node pool configuration, networking setup, and security policies.

Package Information

  • Package Name: azure-mgmt-containerservice
  • Language: Python
  • Installation: pip install azure-mgmt-containerservice
  • API Version: 2025-07-01
  • Python Support: 3.9+

Core Imports

from azure.mgmt.containerservice import ContainerServiceClient
from azure.identity import DefaultAzureCredential

For async operations:

from azure.mgmt.containerservice.aio import ContainerServiceClient as AsyncContainerServiceClient
from azure.identity.aio import DefaultAzureCredential as AsyncDefaultAzureCredential

Basic Usage

from azure.mgmt.containerservice import ContainerServiceClient
from azure.identity import DefaultAzureCredential

# Initialize the client
credential = DefaultAzureCredential()
subscription_id = "your-subscription-id"
client = ContainerServiceClient(credential, subscription_id)

# List all managed clusters
clusters = client.managed_clusters.list()
for cluster in clusters:
    print(f"Cluster: {cluster.name}, Location: {cluster.location}")

# Get a specific cluster
cluster = client.managed_clusters.get("resource-group-name", "cluster-name")
print(f"Cluster status: {cluster.provisioning_state}")

# Close the client
client.close()

Async usage:

import asyncio
from azure.mgmt.containerservice.aio import ContainerServiceClient
from azure.identity.aio import DefaultAzureCredential

async def main():
    credential = DefaultAzureCredential()
    async with ContainerServiceClient(credential, subscription_id) as client:
        # List clusters asynchronously
        clusters = []
        async for cluster in client.managed_clusters.list():
            clusters.append(cluster)
        
        print(f"Found {len(clusters)} clusters")

asyncio.run(main())

Architecture

The client follows the Azure SDK architecture pattern with a main client class that provides access to operation groups:

  • ContainerServiceClient: Main client managing authentication, configuration, and request pipeline
  • Operations Groups: Specialized classes for different resource types (clusters, agent pools, etc.)
  • Models: Strongly-typed data classes representing Azure resources and their properties
  • Long-Running Operations (LRO): Asynchronous operations that return pollers for tracking progress
  • Pagination: Automatic handling of large result sets through async iterators

Both synchronous and asynchronous versions follow the same API patterns, with async methods returning coroutines.

Capabilities

Managed Cluster Operations

Core AKS cluster management including creation, updates, scaling, credential rotation, and deletion. Supports both basic and advanced cluster configurations with comprehensive networking, security, and monitoring options.

def get(resource_group_name: str, resource_name: str, **kwargs) -> ManagedCluster: ...
def begin_create_or_update(resource_group_name: str, resource_name: str, parameters: ManagedCluster, **kwargs) -> LROPoller[ManagedCluster]: ...
def begin_delete(resource_group_name: str, resource_name: str, **kwargs) -> LROPoller[None]: ...
def list(**kwargs) -> ItemPaged[ManagedCluster]: ...
def list_by_resource_group(resource_group_name: str, **kwargs) -> ItemPaged[ManagedCluster]: ...

Managed Clusters

Agent Pool Operations

Node pool management for AKS clusters including system and user node pools, auto-scaling configuration, OS and VM size selection, and maintenance operations.

def get(resource_group_name: str, resource_name: str, agent_pool_name: str, **kwargs) -> AgentPool: ...
def begin_create_or_update(resource_group_name: str, resource_name: str, agent_pool_name: str, parameters: AgentPool, **kwargs) -> LROPoller[AgentPool]: ...
def begin_delete(resource_group_name: str, resource_name: str, agent_pool_name: str, **kwargs) -> LROPoller[None]: ...
def list(resource_group_name: str, resource_name: str, **kwargs) -> ItemPaged[AgentPool]: ...

Agent Pools

Maintenance Configuration

Scheduled maintenance windows and maintenance configuration management for AKS clusters, including both node OS updates and Kubernetes version upgrades.

def get(resource_group_name: str, resource_name: str, config_name: str, **kwargs) -> MaintenanceConfiguration: ...
def create_or_update(resource_group_name: str, resource_name: str, config_name: str, parameters: MaintenanceConfiguration, **kwargs) -> MaintenanceConfiguration: ...
def delete(resource_group_name: str, resource_name: str, config_name: str, **kwargs) -> None: ...
def list_by_managed_cluster(resource_group_name: str, resource_name: str, **kwargs) -> ItemPaged[MaintenanceConfiguration]: ...

Maintenance

Private Networking

Private endpoint connections, private link resources, and private link service ID resolution for secure, private connectivity to AKS clusters.

def get(resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, **kwargs) -> PrivateEndpointConnection: ...
def update(resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, parameters: PrivateEndpointConnection, **kwargs) -> PrivateEndpointConnection: ...
def begin_delete(resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, **kwargs) -> LROPoller[None]: ...
def list(resource_group_name: str, resource_name: str, **kwargs) -> PrivateEndpointConnectionListResult: ...

Private Networking

Snapshots

Node pool snapshot operations for backup, restore, and blue-green deployment scenarios, enabling reliable cluster state management.

def get(resource_group_name: str, resource_name: str, **kwargs) -> Snapshot: ...
def create_or_update(resource_group_name: str, resource_name: str, parameters: Snapshot, **kwargs) -> Snapshot: ...
def delete(resource_group_name: str, resource_name: str, **kwargs) -> None: ...

Snapshots

Trusted Access

Trusted access role bindings and role management for secure integration with other Azure services and custom applications.

def get(resource_group_name: str, resource_name: str, trusted_access_role_binding_name: str, **kwargs) -> TrustedAccessRoleBinding: ...
def begin_create_or_update(resource_group_name: str, resource_name: str, trusted_access_role_binding_name: str, trusted_access_role_binding: TrustedAccessRoleBinding, **kwargs) -> LROPoller[TrustedAccessRoleBinding]: ...
def begin_delete(resource_group_name: str, resource_name: str, trusted_access_role_binding_name: str, **kwargs) -> LROPoller[None]: ...
def list(resource_group_name: str, resource_name: str, **kwargs) -> ItemPaged[TrustedAccessRoleBinding]: ...

Trusted Access

Machine Operations

Individual node/machine management within agent pools, including machine-specific operations, status monitoring, and maintenance actions.

def get(resource_group_name: str, resource_name: str, agent_pool_name: str, machine_name: str, **kwargs) -> Machine: ...
def list(resource_group_name: str, resource_name: str, agent_pool_name: str, **kwargs) -> ItemPaged[Machine]: ...

Machines

Operations Discovery

Lists all available operations in the Azure Container Service provider for API discovery and documentation purposes.

def list(**kwargs) -> ItemPaged[OperationValue]: ...

Private Link Resources

Manages private link resources for AKS managed clusters to enable private cluster functionality and secure connectivity.

def list(resource_group_name: str, resource_name: str, **kwargs) -> PrivateLinkResourcesListResult: ...

Private Link Service Resolution

Resolves private link service IDs for managed clusters, essential for establishing private connectivity configurations.

def post(resource_group_name: str, resource_name: str, parameters: PrivateLinkResource, **kwargs) -> PrivateLinkResource: ...

Trusted Access Roles

Manages trusted access roles that can be granted to external services for secure access to AKS clusters, with regional role definitions.

def list(location: str, **kwargs) -> ItemPaged[TrustedAccessRole]: ...

Core Models and Types

Essential data models representing AKS resources including cluster specifications, agent pool configurations, network profiles, and authentication settings.

class ManagedCluster: ...
class AgentPool: ...
class ContainerServiceNetworkProfile: ...
class ManagedClusterIdentity: ...

Models and Types

Authentication

The client requires Azure credentials with appropriate permissions. Common authentication patterns:

# Using DefaultAzureCredential (recommended)
from azure.identity import DefaultAzureCredential
credential = DefaultAzureCredential()

# Using service principal
from azure.identity import ClientSecretCredential
credential = ClientSecretCredential(
    tenant_id="tenant-id",
    client_id="client-id", 
    client_secret="client-secret"
)

# Using managed identity
from azure.identity import ManagedIdentityCredential
credential = ManagedIdentityCredential()

Error Handling

The client raises standard Azure SDK exceptions:

from azure.core.exceptions import ResourceNotFoundError, HttpResponseError

try:
    cluster = client.managed_clusters.get("rg", "cluster-name")
except ResourceNotFoundError:
    print("Cluster not found")
except HttpResponseError as e:
    print(f"HTTP error: {e.status_code} - {e.message}")