CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-azure-mgmt-computeschedule

Microsoft Azure ComputeSchedule Management Client Library for Python providing VM scheduling operations.

Pending

Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

Overview
Eval results
Files

scheduled-operations.mddocs/

Scheduled Operations

Submit VM operations to be executed at future scheduled times with deadline-based execution control, optimization preferences, and retry policies. These operations allow you to plan VM lifecycle changes in advance.

Capabilities

Submit Deallocate Operation

Schedule virtual machines to be deallocated at a specified future time, releasing compute resources while preserving storage.

def virtual_machines_submit_deallocate(
    self, 
    locationparameter: str, 
    request_body: Union[SubmitDeallocateRequest, JSON, IO[bytes]], 
    **kwargs: Any
) -> DeallocateResourceOperationResponse:
    """
    Submit deallocate operation for VMs to be executed at scheduled time.
    
    Parameters:
    - locationparameter: Azure region where operation will be executed (required)
    - request_body: Deallocate request with schedule and execution parameters (required)
    
    Returns:
    Response containing operation ID and status information
    """

Usage Example:

from azure.mgmt.computeschedule.models import (
    SubmitDeallocateRequest,
    Schedule, 
    ExecutionParameters,
    Resources,
    DeadlineType
)

# Define when to execute the operation
schedule = Schedule(
    deadline_type=DeadlineType.INITIATE_AT,
    deadline="2024-01-15T10:00:00Z",
    timezone="UTC"
)

# Define which VMs and how to execute
execution_params = ExecutionParameters(
    resources=Resources(
        ids=[
            "/subscriptions/{subscription_id}/resourceGroups/myRG/providers/Microsoft.Compute/virtualMachines/vm1",
            "/subscriptions/{subscription_id}/resourceGroups/myRG/providers/Microsoft.Compute/virtualMachines/vm2"
        ]
    )
)

# Create the request
request = SubmitDeallocateRequest(
    schedule=schedule,
    execution_parameters=execution_params
)

# Submit the scheduled operation  
response = client.scheduled_actions.virtual_machines_submit_deallocate(
    locationparameter="eastus",
    request_body=request
)

print(f"Deallocate operation scheduled with ID: {response.operation_id}")

Submit Hibernate Operation

Schedule virtual machines to be hibernated at a specified future time, preserving memory state while stopping compute billing.

def virtual_machines_submit_hibernate(
    self, 
    locationparameter: str, 
    request_body: Union[SubmitHibernateRequest, JSON, IO[bytes]], 
    **kwargs: Any
) -> HibernateResourceOperationResponse:
    """
    Submit hibernate operation for VMs to be executed at scheduled time.
    
    Parameters:
    - locationparameter: Azure region where operation will be executed (required)
    - request_body: Hibernate request with schedule and execution parameters (required)
    
    Returns:
    Response containing operation ID and status information
    """

Usage Example:

from azure.mgmt.computeschedule.models import (
    SubmitHibernateRequest,
    Schedule,
    ExecutionParameters, 
    Resources,
    DeadlineType,
    OptimizationPreference
)

# Schedule for completion by deadline
schedule = Schedule(
    deadline_type=DeadlineType.COMPLETE_BY,
    deadline="2024-01-15T22:00:00Z", 
    timezone="UTC"
)

# Configure execution with optimization
execution_params = ExecutionParameters(
    resources=Resources(
        ids=["/subscriptions/{subscription_id}/resourceGroups/myRG/providers/Microsoft.Compute/virtualMachines/hibernateVM"]
    ),
    optimization_preference=OptimizationPreference.COST
)

request = SubmitHibernateRequest(
    schedule=schedule,
    execution_parameters=execution_params
)

response = client.scheduled_actions.virtual_machines_submit_hibernate(
    locationparameter="westus2",
    request_body=request
)

print(f"Hibernate operation scheduled with ID: {response.operation_id}")

Submit Start Operation

Schedule virtual machines to be started at a specified future time, bringing stopped or deallocated VMs back online.

def virtual_machines_submit_start(
    self, 
    locationparameter: str, 
    request_body: Union[SubmitStartRequest, JSON, IO[bytes]], 
    **kwargs: Any
) -> StartResourceOperationResponse:
    """
    Submit start operation for VMs to be executed at scheduled time.
    
    Parameters:
    - locationparameter: Azure region where operation will be executed (required)
    - request_body: Start request with schedule and execution parameters (required)
    
    Returns:
    Response containing operation ID and status information
    """

Usage Example:

from azure.mgmt.computeschedule.models import (
    SubmitStartRequest,
    Schedule,
    ExecutionParameters,
    Resources,
    RetryPolicy,
    DeadlineType
)

# Schedule start for Monday morning
schedule = Schedule(
    deadline_type=DeadlineType.INITIATE_AT,
    deadline="2024-01-15T08:00:00Z",
    timezone="UTC"
)

# Configure with retry policy
retry_policy = RetryPolicy(
    retry_count=3,
    retry_window_in_minutes=30
)

execution_params = ExecutionParameters(
    resources=Resources(
        ids=[
            "/subscriptions/{subscription_id}/resourceGroups/prodRG/providers/Microsoft.Compute/virtualMachines/webServer1",
            "/subscriptions/{subscription_id}/resourceGroups/prodRG/providers/Microsoft.Compute/virtualMachines/webServer2"
        ]
    ),
    retry_policy=retry_policy
)

request = SubmitStartRequest(
    schedule=schedule,
    execution_parameters=execution_params
)

response = client.scheduled_actions.virtual_machines_submit_start(
    locationparameter="eastus",
    request_body=request
)

print(f"Start operation scheduled with ID: {response.operation_id}")

Schedule Configuration

Schedule Types

Configure when operations should be executed using deadline types:

  • INITIATE_AT: Begin operation at specified deadline time
  • COMPLETE_BY: Ensure operation completes by specified deadline time
  • UNKNOWN: Default/unspecified deadline type

Time Zone Support

Specify time zones for accurate scheduling across regions:

# UTC timezone (recommended for consistency)
schedule = Schedule(
    deadline_type=DeadlineType.INITIATE_AT,
    deadline="2024-01-15T10:00:00Z",
    timezone="UTC"
)

# Regional timezone
schedule = Schedule(
    deadline_type=DeadlineType.INITIATE_AT, 
    deadline="2024-01-15T10:00:00",
    timezone="America/New_York"
)

Execution Parameters

Configure how operations are executed:

from azure.mgmt.computeschedule.models import (
    ExecutionParameters,
    Resources, 
    OptimizationPreference,
    RetryPolicy
)

execution_params = ExecutionParameters(
    # Target VMs by resource ID
    resources=Resources(
        ids=[
            "/subscriptions/{subscription_id}/resourceGroups/{rg}/providers/Microsoft.Compute/virtualMachines/{vm}"
        ]
    ),
    # Optimize for cost or speed
    optimization_preference=OptimizationPreference.COST,
    # Configure retry behavior
    retry_policy=RetryPolicy(
        retry_count=3,
        retry_window_in_minutes=30
    )
)

Install with Tessl CLI

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

docs

client-setup.md

immediate-operations.md

index.md

models-types.md

operation-management.md

scheduled-operations.md

tile.json