CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-azure-mgmt-batch

Microsoft Azure Batch Management Client Library for Python

Pending

Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

Overview
Eval results
Files

applications.mddocs/

Application Management

Deployment and version management for applications that run on Batch compute nodes, including application packages and version control.

Core Imports

from azure.mgmt.batch.operations import ApplicationOperations, ApplicationPackageOperations
from azure.mgmt.batch.models import Application, ApplicationPackage, ActivateApplicationPackageParameters
from azure.core.paging import ItemPaged
from typing import Union, Optional, IO, Any

Capabilities

Application Creation

Creates new applications within a Batch account for deployment to compute nodes.

def create(
    resource_group_name: str,
    account_name: str,
    application_name: str,
    parameters: Application = None,
    **kwargs: Any
) -> Application:
    """
    Adds an application to the specified Batch account.
    
    Args:
        resource_group_name (str): The name of the resource group
        account_name (str): The name of the Batch account
        application_name (str): The name of the application
        parameters (Application, optional): Application creation parameters
        
    Returns:
        Application: The created application
    """

Application Retrieval

Retrieves detailed information about an existing application.

def get(
    resource_group_name: str,
    account_name: str,
    application_name: str,
    **kwargs: Any
) -> Application:
    """
    Gets information about the specified application.
    
    Args:
        resource_group_name (str): The name of the resource group
        account_name (str): The name of the Batch account
        application_name (str): The name of the application
        
    Returns:
        Application: The application details
    """

Application Updates

Updates application properties including display name, default version, and update permissions.

def update(
    resource_group_name: str,
    account_name: str,
    application_name: str,
    parameters: Application,
    **kwargs: Any
) -> Application:
    """
    Updates settings for the specified application.
    
    Args:
        resource_group_name (str): The name of the resource group
        account_name (str): The name of the Batch account
        application_name (str): The name of the application
        parameters (Application): Application update parameters
        
    Returns:
        Application: The updated application
    """

Application Deletion

Deletes an application and all its versions.

def delete(
    resource_group_name: str,
    account_name: str,
    application_name: str,
    **kwargs: Any
) -> None:
    """
    Deletes an application.
    
    Args:
        resource_group_name (str): The name of the resource group
        account_name (str): The name of the Batch account
        application_name (str): The name of the application
    """

Application Listing

Lists all applications within a Batch account.

def list(
    resource_group_name: str,
    account_name: str,
    maxresults: int = None,
    **kwargs: Any
) -> ItemPaged[Application]:
    """
    Lists all applications in the specified account.
    
    Args:
        resource_group_name (str): The name of the resource group
        account_name (str): The name of the Batch account
        maxresults (int, optional): Maximum number of results to return
        
    Returns:
        ItemPaged[Application]: Paginated list of applications
    """

Application Package Operations

Application packages contain the binary files deployed to compute nodes for task execution.

Package Creation

Creates an application package record with a storage URL for uploading package contents.

def create(
    resource_group_name: str,
    account_name: str,
    application_name: str,
    version_name: str,
    parameters: Optional[Union[ApplicationPackage, IO[bytes]]] = None,
    **kwargs: Any
) -> ApplicationPackage:
    """
    Creates an application package record. The record contains a storageUrl where the package 
    should be uploaded to. Once uploaded, the ApplicationPackage needs to be activated.
    
    Args:
        resource_group_name (str): The name of the resource group
        account_name (str): The name of the Batch account
        application_name (str): The name of the application
        version_name (str): The version of the application
        parameters (ApplicationPackage | IO[bytes], optional): Package parameters
        
    Returns:
        ApplicationPackage: The created application package with storage URL
    """

Package Activation

Activates an uploaded package to make it available for deployment to compute nodes.

def activate(
    resource_group_name: str,
    account_name: str,
    application_name: str,
    version_name: str,
    parameters: Union[ActivateApplicationPackageParameters, IO[bytes]],
    **kwargs: Any
) -> ApplicationPackage:
    """
    Activates the specified application package. This should be done after the 
    ApplicationPackage was created and uploaded. This needs to be done before an 
    ApplicationPackage can be used on Pools or Tasks.
    
    Args:
        resource_group_name (str): The name of the resource group
        account_name (str): The name of the Batch account
        application_name (str): The name of the application
        version_name (str): The version of the application
        parameters (ActivateApplicationPackageParameters | IO[bytes]): Activation parameters
        
    Returns:
        ApplicationPackage: The activated application package
    """

Package Retrieval

Gets information about a specific application package version.

def get(
    resource_group_name: str,
    account_name: str,
    application_name: str,
    version_name: str,
    **kwargs: Any
) -> ApplicationPackage:
    """
    Gets information about the specified application package.
    
    Args:
        resource_group_name (str): The name of the resource group
        account_name (str): The name of the Batch account
        application_name (str): The name of the application
        version_name (str): The version of the application
        
    Returns:
        ApplicationPackage: The application package details
    """

Package Deletion

Deletes an application package record and its associated binary file.

def delete(
    resource_group_name: str,
    account_name: str,
    application_name: str,
    version_name: str,
    **kwargs: Any
) -> None:
    """
    Deletes an application package record and its associated binary file.
    
    Args:
        resource_group_name (str): The name of the resource group
        account_name (str): The name of the Batch account
        application_name (str): The name of the application
        version_name (str): The version of the application
    """

Package Listing

Lists all package versions for an application.

def list(
    resource_group_name: str,
    account_name: str,
    application_name: str,
    maxresults: Optional[int] = None,
    **kwargs: Any
) -> ItemPaged[ApplicationPackage]:
    """
    Lists all of the application packages in the specified application.
    
    Args:
        resource_group_name (str): The name of the resource group
        account_name (str): The name of the Batch account
        application_name (str): The name of the application
        maxresults (int, optional): Maximum number of items to return in the response
        
    Returns:
        ItemPaged[ApplicationPackage]: An iterator of ApplicationPackage objects
    """

Types

Application Types

class Application:
    id: str
    name: str
    type: str
    etag: str
    display_name: str
    allow_updates: bool
    default_version: str
    
class ApplicationPackage:
    id: str
    name: str
    type: str
    etag: str
    state: PackageState
    format: str
    storage_url: str
    storage_url_expiry: datetime
    last_activation_time: datetime
    
class ActivateApplicationPackageParameters:
    format: str
    
class ApplicationPackageReference:
    id: str
    version: str

Usage Examples

Creating and Managing Applications

# Create a new application
app_params = {
    "display_name": "My Batch Application",
    "allow_updates": True
}

application = client.application.create(
    "my-resource-group",
    "my-batch-account", 
    "my-app",
    app_params
)
print(f"Created application: {application.display_name}")

# Update application settings
update_params = {
    "display_name": "Updated Application Name",
    "allow_updates": False,
    "default_version": "1.0"
}

updated_app = client.application.update(
    "my-resource-group",
    "my-batch-account",
    "my-app",
    update_params
)

Managing Application Packages

from azure.mgmt.batch.models import ActivateApplicationPackageParameters

# Create a new application package version
package = client.application_package.create(
    "my-resource-group",
    "my-batch-account",
    "my-app",
    "1.0"
)
print(f"Package URL for upload: {package.storage_url}")

# Upload your application files to the storage_url
# (This would be done using Azure Storage SDK or REST API)

# Activate the package after uploading files
activation_params = ActivateApplicationPackageParameters(format="zip")
activated_package = client.application_package.activate(
    "my-resource-group",
    "my-batch-account", 
    "my-app",
    "1.0",
    activation_params
)
print(f"Package state: {activated_package.state}")

Using Applications in Pool Configuration

from azure.mgmt.batch.models import ApplicationPackageReference

# Reference application packages in pool configuration
app_packages = [
    ApplicationPackageReference(id="my-app", version="1.0"),
    ApplicationPackageReference(id="my-other-app", version="2.1")
]

# Use in pool creation (this would be part of a Pool object)
pool_config = {
    "application_packages": app_packages,
    # ... other pool configuration
}

Listing and Monitoring Applications

# List all applications
applications = client.application.list("my-resource-group", "my-batch-account")
for app in applications:
    print(f"Application: {app.name}, Default Version: {app.default_version}")
    
    # List packages for each application
    packages = client.application_package.list(
        "my-resource-group", 
        "my-batch-account", 
        app.name
    )
    for package in packages:
        print(f"  Package: {package.name}, State: {package.state}")

Install with Tessl CLI

npx tessl i tessl/pypi-azure-mgmt-batch

docs

applications.md

batch-accounts.md

certificates.md

index.md

location-services.md

network-security.md

pools.md

tile.json