or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

authentication.mdcontainer-groups.mdcontainers.mdindex.mdlocation.mdmodels.mdoperations.mdsubnet-operations.md
tile.json

tessl/pypi-azure-mgmt-containerinstance

Microsoft Azure Container Instance Client Library for Python providing comprehensive management capabilities for containerized applications in Azure cloud.

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

To install, run

npx @tessl/cli install tessl/pypi-azure-mgmt-containerinstance@10.1.0

index.mddocs/

Azure Container Instance Management Library

Overview

The azure-mgmt-containerinstance package provides a comprehensive Python client library for managing Azure Container Instances. It enables developers to programmatically create, configure, and manage containerized applications in the Azure cloud through a complete API wrapper for Azure Container Instance REST endpoints.

Package Information

  • Package Name: azure-mgmt-containerinstance
  • Package Type: pypi
  • Language: Python
  • Installation: pip install azure-mgmt-containerinstance

Core Imports

# Main client
from azure.mgmt.containerinstance import ContainerInstanceManagementClient

# Authentication
from azure.identity import DefaultAzureCredential

# Core models
from azure.mgmt.containerinstance.models import (
    ContainerGroup,
    Container,
    ContainerGroupProperties,
    ResourceRequirements,
    ResourceRequests,
    IpAddress,
    ContainerPort
)

Basic Usage

Client Setup and Authentication

from azure.identity import DefaultAzureCredential
from azure.mgmt.containerinstance import ContainerInstanceManagementClient
import os

# Setup authentication - requires AZURE_CLIENT_ID, AZURE_TENANT_ID, AZURE_CLIENT_SECRET
credential = DefaultAzureCredential()
subscription_id = os.getenv("AZURE_SUBSCRIPTION_ID")

# Create client
client = ContainerInstanceManagementClient(
    credential=credential,
    subscription_id=subscription_id
)

Simple Container Group Creation

from azure.mgmt.containerinstance.models import (
    ContainerGroup,
    Container,
    ContainerGroupProperties,
    ResourceRequirements,
    ResourceRequests,
    IpAddress,
    ContainerPort
)

# Define container
container = Container(
    name="my-container",
    image="nginx:latest",
    resources=ResourceRequirements(
        requests=ResourceRequests(memory_in_gb=1.0, cpu=1.0)
    ),
    ports=[ContainerPort(port=80)]
)

# Define container group
container_group = ContainerGroup(
    location="East US",
    containers=[container],
    os_type="Linux",
    ip_address=IpAddress(
        type="Public",
        ports=[ContainerPort(port=80, protocol="TCP")]
    )
)

# Create container group
operation = client.container_groups.begin_create_or_update(
    resource_group_name="my-resource-group",
    container_group_name="my-container-group",
    container_group=container_group
)
result = operation.result()

Architecture

The Azure Container Instance Management Client follows the standard Azure SDK patterns:

  • Client: ContainerInstanceManagementClient - Main entry point for all operations
  • Operations: Specialized operation classes for different resource types
  • Models: Data classes representing Azure resources and configurations
  • Authentication: Azure Active Directory token-based authentication via azure-identity

Capabilities

Container Group Management

Comprehensive CRUD operations for Azure Container Groups including creation, updates, deletion, and lifecycle management.

def list(**kwargs) -> ItemPaged[ContainerGroup]:
    """List all container groups in the subscription."""

def list_by_resource_group(resource_group_name: str, **kwargs) -> ItemPaged[ContainerGroup]:
    """List container groups in a specific resource group."""

def get(resource_group_name: str, container_group_name: str, **kwargs) -> ContainerGroup:
    """Get details of a specific container group."""

def begin_create_or_update(
    resource_group_name: str,
    container_group_name: str,
    container_group: ContainerGroup,
    **kwargs
) -> LROPoller[ContainerGroup]:
    """Create a new container group or update an existing one."""

def update(
    resource_group_name: str,
    container_group_name: str,
    resource: Resource,
    **kwargs
) -> ContainerGroup:
    """Update container group tags."""

def begin_delete(
    resource_group_name: str,
    container_group_name: str,
    **kwargs
) -> LROPoller[ContainerGroup]:
    """Delete a container group and all its containers."""

def begin_restart(
    resource_group_name: str,
    container_group_name: str,
    **kwargs
) -> LROPoller[None]:
    """Restart all containers in a container group."""

def stop(resource_group_name: str, container_group_name: str, **kwargs) -> None:
    """Stop all containers in a container group."""

def begin_start(
    resource_group_name: str,
    container_group_name: str,
    **kwargs
) -> LROPoller[None]:
    """Start all containers in a stopped container group."""

def get_outbound_network_dependencies_endpoints(
    resource_group_name: str,
    container_group_name: str,
    **kwargs
) -> List[str]:
    """Get outbound network dependencies for a container group."""

Container Group Operations

Container Management

Direct container operations including log retrieval, command execution, and container attachment.

def list_logs(
    resource_group_name: str,
    container_group_name: str,
    container_name: str,
    **kwargs
) -> Logs:
    """Retrieve logs from a specific container."""

def execute_command(
    resource_group_name: str,
    container_group_name: str,
    container_name: str,
    container_exec_request: ContainerExecRequest,
    **kwargs
) -> ContainerExecResponse:
    """Execute a command inside a running container."""

def attach(
    resource_group_name: str,
    container_group_name: str,
    container_name: str,
    **kwargs
) -> ContainerAttachResponse:
    """Attach to a container's main process for interactive access."""

Container Operations

Authentication and Configuration

Azure Active Directory authentication setup and client configuration options.

class ContainerInstanceManagementClient:
    """
    ContainerInstanceManagementClient.
    
    Args:
        credential (TokenCredential): Credential needed for the client to connect to Azure
        subscription_id (str): Subscription credentials which uniquely identify Microsoft Azure subscription
        base_url (str, optional): Service URL. Default value is "https://management.azure.com"
        api_version (str, optional): Api Version. Default value is "2023-05-01"
        polling_interval (int, optional): Default waiting time between two polls for LRO operations
    """

Authentication Guide

Resource Models and Types

Complete type definitions for all Azure Container Instance resources including container groups, containers, volumes, and networking configurations.

class ContainerGroup:
    """Primary resource representing a collection of containers that share lifecycle and resources."""

class Container:
    """Individual container definition with image, resources, and configuration."""

class ResourceRequirements:
    """Container resource requirements including CPU and memory."""

class ResourceRequests:
    """Minimum resources required for container execution."""

class ResourceLimits:
    """Maximum resources a container can consume."""

class IpAddress:
    """Public IP address configuration for container group."""

class ContainerPort:
    """Port configuration for container networking."""

class Volume:
    """Storage volume that can be mounted to containers."""

class VolumeMount:
    """Volume mount point configuration for containers."""

Resource Models

Location and Capabilities

Query Azure regions and container capabilities for deployment planning.

def list_usage(location: str, **kwargs) -> Iterable[Usage]:
    """Get resource usage information for a specific Azure region."""

def list_cached_images(location: str, **kwargs) -> Iterable[CachedImages]:
    """Get list of cached container images available in a specific Azure region."""

def list_capabilities(location: str, **kwargs) -> Iterable[Capabilities]:
    """Get container capabilities and features available in a specific Azure region."""

Location Operations

Available Operations

List all available operations for the Azure Container Instance resource provider.

def list(**kwargs) -> Iterable[Operation]:
    """List all available operations for the Microsoft.ContainerInstance resource provider."""

Operations Reference

Subnet Service Association Links

Manage virtual network subnet service association links for container groups.

def begin_delete(
    resource_group_name: str,
    virtual_network_name: str,
    subnet_name: str,
    service_association_link_name: str,
    **kwargs
) -> LROPoller[None]:
    """Delete a subnet service association link."""

Subnet Operations