Microsoft Azure Data Migration Client Library for Python providing comprehensive database migration management capabilities
Service-level task management for operations performed by Data Migration Service instances. Service tasks are proxy-only resources that represent work performed by a DMS instance, distinct from project-specific migration tasks.
Create, retrieve, update, and delete service tasks. Service tasks have minimal mutable properties as they represent work performed by the DMS instance.
def create_or_update(group_name: str, service_name: str, task_name: str, parameters: ProjectTask, **kwargs) -> ProjectTask:
"""
Create or update service task.
The service tasks resource is a nested, proxy-only resource representing work performed by a
DMS instance. The PUT method creates a new service task or updates an existing one, although
since service tasks have no mutable custom properties, there is little reason to update an
existing one.
Parameters:
- group_name: str - Name of the resource group
- service_name: str - Name of the service
- task_name: str - Name of the task
- parameters: ProjectTask - Information about the task
Returns:
ProjectTask - The task object
"""
def get(group_name: str, service_name: str, task_name: str, expand: str = None, **kwargs) -> ProjectTask:
"""
Get service task information.
The service tasks resource is a nested, proxy-only resource representing work performed by a
DMS instance. The GET method retrieves information about a service task.
Parameters:
- group_name: str - Name of the resource group
- service_name: str - Name of the service
- task_name: str - Name of the task
- expand: str - Expand the response
Returns:
ProjectTask - The task object
"""
def update(group_name: str, service_name: str, task_name: str, parameters: ProjectTask, **kwargs) -> ProjectTask:
"""
Update service task.
The service tasks resource is a nested, proxy-only resource representing work performed by a
DMS instance. The PATCH method updates an existing service task, but since service tasks have
no mutable custom properties, there is little reason to do so.
Parameters:
- group_name: str - Name of the resource group
- service_name: str - Name of the service
- task_name: str - Name of the task
- parameters: ProjectTask - Information about the task
Returns:
ProjectTask - The updated task object
"""
def delete(group_name: str, service_name: str, task_name: str, delete_running_tasks: bool = None, **kwargs) -> None:
"""
Delete service task.
The service tasks resource is a nested, proxy-only resource representing work performed by a
DMS instance. The DELETE method deletes a service task, canceling it first if it's running.
Parameters:
- group_name: str - Name of the resource group
- service_name: str - Name of the service
- task_name: str - Name of the task
- delete_running_tasks: bool - Delete the resource even if tasks are running
Returns:
None
"""List and manage service tasks with filtering capabilities and task control operations.
def list(group_name: str, service_name: str, task_type: str = None, **kwargs) -> ItemPaged[TaskList]:
"""
Get service level tasks for a service.
The services resource is the top-level resource that represents the Database Migration Service.
This method returns a list of service level tasks owned by a service resource. Some tasks may
have a status of Unknown, which indicates that an error occurred while querying the status of
that task.
Parameters:
- group_name: str - Name of the resource group
- service_name: str - Name of the service
- task_type: str - Filter tasks by task type
Returns:
ItemPaged[TaskList] - A paged list of service tasks
"""
def cancel(group_name: str, service_name: str, task_name: str, **kwargs) -> ProjectTask:
"""
Cancel a service task.
The service tasks resource is a nested, proxy-only resource representing work performed by a
DMS instance. This method cancels a service task if it's currently queued or running.
Parameters:
- group_name: str - Name of the resource group
- service_name: str - Name of the service
- task_name: str - Name of the task
Returns:
ProjectTask - The canceled task object
"""from azure.mgmt.datamigration import DataMigrationManagementClient
from azure.identity import DefaultAzureCredential
# Create client
credential = DefaultAzureCredential()
client = DataMigrationManagementClient(
credential=credential,
subscription_id="your-subscription-id"
)
# List all service tasks
service_tasks = client.service_tasks.list(
group_name="my-resource-group",
service_name="my-migration-service"
)
for task in service_tasks:
print(f"Task: {task.name}, State: {task.state}")
# Get specific service task
task = client.service_tasks.get(
group_name="my-resource-group",
service_name="my-migration-service",
task_name="my-service-task"
)
# Cancel a running service task
client.service_tasks.cancel(
group_name="my-resource-group",
service_name="my-migration-service",
task_name="my-service-task"
)from azure.mgmt.datamigration.models import ProjectTask
# Create a service task (typically done by the service itself)
task_params = ProjectTask(
properties={} # Service task properties are managed by DMS
)
created_task = client.service_tasks.create_or_update(
group_name="my-resource-group",
service_name="my-migration-service",
task_name="new-service-task",
parameters=task_params
)
# Delete service task when complete
client.service_tasks.delete(
group_name="my-resource-group",
service_name="my-migration-service",
task_name="completed-service-task"
)
client.close()class TaskList:
"""List of service tasks."""
value: List[ProjectTask]
next_link: str
class ProjectTask:
"""Service task representation."""
name: str
task_type: str
state: str
properties: ProjectTaskPropertiestessl i tessl/pypi-azure-mgmt-datamigration@9.0.0