Azure Data Migration Client Library for programmatically managing database migration services and operations.
—
Quality
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Service-level tasks that operate independently of specific projects, including driver management and service-wide operations. These tasks perform maintenance and configuration operations at the Data Migration Service level.
Creates a new service task or updates an existing one.
def create_or_update(
group_name: str,
service_name: str,
task_name: str,
parameters: ProjectTask,
**kwargs
) -> ProjectTask:
"""
Creates or updates a service-level task.
Parameters:
- group_name: Name of the resource group
- service_name: Name of the Data Migration Service
- task_name: Name of the service task
- parameters: Task configuration and properties
Returns:
ProjectTask object with current state and results
"""Retrieves details and status of a service task.
def get(
group_name: str,
service_name: str,
task_name: str,
expand: str = None,
**kwargs
) -> ProjectTask:
"""
Gets a service task with current status and results.
Parameters:
- group_name: Name of the resource group
- service_name: Name of the Data Migration Service
- task_name: Name of the service task
- expand: Properties to expand (e.g., "output")
Returns:
ProjectTask with current state and results
"""Deletes a service task.
def delete(
group_name: str,
service_name: str,
task_name: str,
delete_running_tasks: bool = None,
**kwargs
) -> None:
"""
Deletes a service task.
Parameters:
- group_name: Name of the resource group
- service_name: Name of the Data Migration Service
- task_name: Name of the service task
- delete_running_tasks: Whether to delete if running
Returns:
None
"""Updates properties of an existing service task.
def update(
group_name: str,
service_name: str,
task_name: str,
parameters: ProjectTask,
**kwargs
) -> ProjectTask:
"""
Updates a service task.
Parameters:
- group_name: Name of the resource group
- service_name: Name of the Data Migration Service
- task_name: Name of the service task
- parameters: Updated task properties
Returns:
Updated ProjectTask object
"""Cancels a running service task.
def cancel(
group_name: str,
service_name: str,
task_name: str,
**kwargs
) -> ProjectTask:
"""
Cancels a running service task.
Parameters:
- group_name: Name of the resource group
- service_name: Name of the Data Migration Service
- task_name: Name of the service task
Returns:
ProjectTask with updated state
"""Lists all service tasks within a Data Migration Service.
def list(
group_name: str,
service_name: str,
task_type: str = None,
**kwargs
) -> ItemPaged[ProjectTask]:
"""
Lists service tasks in a Data Migration Service.
Parameters:
- group_name: Name of the resource group
- service_name: Name of the Data Migration Service
- task_type: Filter by task type (optional)
Returns:
Paged collection of ProjectTask objects
"""Service tasks for managing Oracle OCI drivers required for Oracle database migrations.
class CheckOCIDriverTaskProperties(ProjectTaskProperties):
"""Check Oracle OCI driver installation status."""
def __init__(self, input: CheckOCIDriverTaskInput = None, **kwargs):
"""
Parameters:
- input: Driver check input (optional)
"""
# Properties
input: CheckOCIDriverTaskInput
output: List[CheckOCIDriverTaskOutput]class InstallOCIDriverTaskProperties(ProjectTaskProperties):
"""Install Oracle OCI driver on the service."""
def __init__(self, input: InstallOCIDriverTaskInput = None, **kwargs):
"""
Parameters:
- input: Driver installation input (optional)
"""
# Properties
input: InstallOCIDriverTaskInput
output: List[InstallOCIDriverTaskOutput]class UploadOCIDriverTaskProperties(ProjectTaskProperties):
"""Upload Oracle OCI driver to the service."""
def __init__(self, input: UploadOCIDriverTaskInput, **kwargs):
"""
Parameters:
- input: Driver upload input with driver package details
"""
# Properties
input: UploadOCIDriverTaskInput
output: List[UploadOCIDriverTaskOutput]class CheckOCIDriverTaskInput:
"""Input for checking OCI driver status."""
def __init__(self, **kwargs): ...
# No specific properties - uses service defaults
class InstallOCIDriverTaskInput:
"""Input for installing OCI driver."""
def __init__(self, driver_package_name: str = None, **kwargs):
"""
Parameters:
- driver_package_name: Name of driver package to install
"""
# Properties
driver_package_name: str # Optional: specific driver package
class UploadOCIDriverTaskInput:
"""Input for uploading OCI driver."""
def __init__(self, driver_share: BlobShare, **kwargs):
"""
Parameters:
- driver_share: Blob storage location containing driver package
"""
# Properties
driver_share: BlobShare # Required: storage location with driverclass CheckOCIDriverTaskOutput:
"""Output from OCI driver check."""
# Properties
version: str # Installed driver version
ooci_driver_info: List[OracleOCIDriverInfo] # Driver details
validation_errors: List[ReportableException] # Any issues found
class InstallOCIDriverTaskOutput:
"""Output from OCI driver installation."""
# Properties
validation_errors: List[ReportableException] # Installation errors
installation_logs: List[str] # Installation log messages
class UploadOCIDriverTaskOutput:
"""Output from OCI driver upload."""
# Properties
validation_errors: List[ReportableException] # Upload errors
uploaded_driver_info: OracleOCIDriverInfo # Uploaded driver detailsclass OracleOCIDriverInfo:
"""Oracle OCI driver information."""
# Properties
driver_name: str # Driver package name
driver_size: str # Driver package size
ooci_driver_path: str # Installation path
version: str # Driver version
archive_checksum: str # Package checksum for validationfrom azure.mgmt.datamigration.models import (
ProjectTask,
CheckOCIDriverTaskProperties,
InstallOCIDriverTaskProperties,
UploadOCIDriverTaskProperties,
UploadOCIDriverTaskInput,
BlobShare
)
# 1. Check current driver status
check_driver_task = ProjectTask(
properties=CheckOCIDriverTaskProperties()
)
task = client.service_tasks.create_or_update(
group_name="myResourceGroup",
service_name="myMigrationService",
task_name="checkOCIDriver",
parameters=check_driver_task
)
# Wait for completion and check results
check_result = client.service_tasks.get(
group_name="myResourceGroup",
service_name="myMigrationService",
task_name="checkOCIDriver",
expand="output"
)
if check_result.properties.output:
driver_info = check_result.properties.output[0]
print(f"Current driver version: {driver_info.version}")
# 2. Upload new driver if needed
driver_share = BlobShare(
sas_uri="https://mystorageaccount.blob.core.windows.net/drivers?sv=..."
)
upload_driver_task = ProjectTask(
properties=UploadOCIDriverTaskProperties(
input=UploadOCIDriverTaskInput(
driver_share=driver_share
)
)
)
upload_task = client.service_tasks.create_or_update(
group_name="myResourceGroup",
service_name="myMigrationService",
task_name="uploadOCIDriver",
parameters=upload_driver_task
)
# 3. Install the uploaded driver
install_driver_task = ProjectTask(
properties=InstallOCIDriverTaskProperties()
)
install_task = client.service_tasks.create_or_update(
group_name="myResourceGroup",
service_name="myMigrationService",
task_name="installOCIDriver",
parameters=install_driver_task
)
print("Oracle OCI driver management tasks initiated")import time
def monitor_service_task(client, group_name, service_name, task_name):
"""Monitor service task execution until completion."""
while True:
task = client.service_tasks.get(
group_name=group_name,
service_name=service_name,
task_name=task_name,
expand="output"
)
state = task.properties.state
print(f"Service task {task_name} state: {state}")
if state in ["Succeeded", "Failed", "Canceled"]:
if task.properties.errors:
print("Task errors:")
for error in task.properties.errors:
print(f" - {error.message}")
break
time.sleep(30)
return task
# Example usage
completed_task = monitor_service_task(
client,
"myResourceGroup",
"myMigrationService",
"installOCIDriver"
)Common service task errors:
Service tasks typically require elevated permissions and may take significant time to complete, especially driver installation operations. Monitor task progress and handle errors appropriately based on the specific operation being performed.
Install with Tessl CLI
npx tessl i tessl/pypi-azure-mgmt-datamigration