CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-azure-batch

Microsoft Azure Batch Client Library for Python providing comprehensive APIs for managing batch computing workloads in Azure cloud

91

1.07x
Overview
Eval results
Files

client-management.mddocs/

Client Management

Core client initialization, configuration, and authentication management for accessing Azure Batch services. The client provides the main entry point for all Batch operations and handles authentication, configuration, and operation routing.

Capabilities

BatchServiceClient

The primary client class for issuing REST requests to the Azure Batch service. Provides access to all Batch operations through specialized operation classes.

class BatchServiceClient:
    """
    A client for issuing REST requests to the Azure Batch service.
    
    Args:
        credentials: Authentication credentials (SharedKeyCredentials or Azure AD)
        batch_url: Base URL for Azure Batch service requests
        
    Attributes:
        application: ApplicationOperations instance
        pool: PoolOperations instance  
        account: AccountOperations instance
        certificate: CertificateOperations instance
        file: FileOperations instance
        job_schedule: JobScheduleOperations instance
        job: JobOperations instance
        task: TaskOperations instance
        compute_node: ComputeNodeOperations instance
        compute_node_extension: ComputeNodeExtensionOperations instance
        api_version: API version string (2024-02-01.19.0)
    """
    def __init__(self, credentials, batch_url: str): ...

SharedKeyCredentials

Shared key authentication for Azure Batch using account name and access key. This is the most common authentication method for Batch applications.

class SharedKeyCredentials:
    """
    Shared key authentication for Azure Batch.
    
    Args:
        account_name: Name of the Batch account
        key: Primary or secondary access key for the account
    """
    def __init__(self, account_name: str, key: str): ...
    def signed_session(self, session=None): ...

BatchServiceClientConfiguration

Configuration settings for the BatchServiceClient including credentials, endpoint, and request settings.

class BatchServiceClientConfiguration:
    """
    Configuration for BatchServiceClient.
    
    Args:
        credentials: Authentication credentials
        batch_url: Base URL for Batch service
    """
    def __init__(self, credentials, batch_url: str): ...

Usage Examples

Basic Client Setup

from azure.batch import BatchServiceClient
from azure.batch.batch_auth import SharedKeyCredentials

# Create credentials
credentials = SharedKeyCredentials(
    account_name="mybatchaccount",
    key="your_primary_or_secondary_key"
)

# Create client
batch_url = "https://mybatchaccount.eastus.batch.azure.com"
client = BatchServiceClient(credentials, batch_url)

# Access operations
pools = client.pool.list()
jobs = client.job.list()

Error Handling

from azure.batch.models import BatchErrorException

try:
    pool = client.pool.get("nonexistent-pool")
except BatchErrorException as e:
    print(f"Batch error: {e.error.code} - {e.error.message}")
    for detail in e.error.values:
        print(f"  {detail.key}: {detail.value}")

Using Different Authentication

# With Azure Active Directory (requires azure-identity)
from azure.identity import DefaultAzureCredential
from msrest.authentication import TokenCredential

# For Azure AD authentication, use the standard Azure identity libraries
credential = DefaultAzureCredential()
# Note: Azure Batch typically uses SharedKeyCredentials
# Azure AD auth requires additional configuration

Types

Configuration Types

class BatchServiceClientConfiguration:
    """Client configuration settings."""
    def __init__(self):
        self.credentials: Any
        self.batch_url: str
        self.base_url: str
        self.filepath: str

Authentication Types

class SharedKeyAuth:
    """Internal shared key authentication implementation."""
    def __init__(self, header: str, account_name: str, key: str): ...
    def __call__(self, request): ...

Install with Tessl CLI

npx tessl i tessl/pypi-azure-batch

docs

account-operations.md

application-operations.md

certificate-operations.md

client-management.md

compute-node-extension-operations.md

compute-node-operations.md

file-operations.md

index.md

job-operations.md

job-schedule-operations.md

pool-operations.md

task-operations.md

tile.json