Azure Data Migration Client Library for programmatically managing database migration services and operations.
npx @tessl/cli install tessl/pypi-azure-mgmt-datamigration@10.0.0A comprehensive Python client library for Microsoft Azure Data Migration services, implementing Azure Resource Manager (ARM) APIs for managing database migration operations. This library enables developers to programmatically create, configure, and monitor data migration projects and services within the Azure ecosystem, supporting various database migration scenarios including SQL Server to Azure SQL Database, MySQL migrations, Oracle to PostgreSQL, and MongoDB migrations.
pip install azure-mgmt-datamigrationfrom azure.mgmt.datamigration import DataMigrationManagementClientFor async operations:
from azure.mgmt.datamigration.aio import DataMigrationManagementClientCommon models and types:
from azure.mgmt.datamigration.models import (
DataMigrationService,
Project,
ProjectTask,
SqlConnectionInfo,
MySqlConnectionInfo,
PostgreSqlConnectionInfo,
MongoDbConnectionInfo
)from azure.identity import DefaultAzureCredential
from azure.mgmt.datamigration import DataMigrationManagementClient
# Create the client
credential = DefaultAzureCredential()
client = DataMigrationManagementClient(
credential=credential,
subscription_id="your-subscription-id"
)
# List migration services
services = client.services.list()
for service in services:
print(f"Service: {service.name}, Location: {service.location}")
# Get service details
service = client.services.get(
group_name="myResourceGroup",
service_name="myMigrationService"
)
# List projects in a service
projects = client.projects.list(
group_name="myResourceGroup",
service_name="myMigrationService"
)
# Create a new migration project
from azure.mgmt.datamigration.models import Project
project_params = Project(
location="eastus",
source_platform="SQL",
target_platform="SQLDB"
)
project = client.projects.create_or_update(
group_name="myResourceGroup",
service_name="myMigrationService",
project_name="myProject",
parameters=project_params
)
print(f"Created project: {project.name}")The Azure Data Migration Management Client follows Azure Resource Manager patterns and provides:
The library abstracts the complexity of Azure's Data Migration Service REST APIs while providing full access to advanced migration features, monitoring capabilities, and multi-database platform support.
Core operations for managing Azure Data Migration Service instances, including creation, configuration, lifecycle management, and monitoring.
# Key service operations
def begin_create_or_update(group_name: str, service_name: str, parameters: DataMigrationService) -> LROPoller[DataMigrationService]: ...
def get(group_name: str, service_name: str) -> DataMigrationService: ...
def begin_delete(group_name: str, service_name: str) -> LROPoller[None]: ...
def begin_start(group_name: str, service_name: str) -> LROPoller[None]: ...
def begin_stop(group_name: str, service_name: str) -> LROPoller[None]: ...
def list() -> ItemPaged[DataMigrationService]: ...Operations for managing migration projects within Data Migration services, organizing related migration tasks and configurations.
# Key project operations
def create_or_update(group_name: str, service_name: str, project_name: str, parameters: Project) -> Project: ...
def get(group_name: str, service_name: str, project_name: str) -> Project: ...
def delete(group_name: str, service_name: str, project_name: str) -> None: ...
def list(group_name: str, service_name: str) -> ItemPaged[Project]: ...Execute and manage various migration and validation tasks including connection testing, schema migration, data migration, and assessment operations.
# Key task operations
def create_or_update(group_name: str, service_name: str, project_name: str, task_name: str, parameters: ProjectTask) -> ProjectTask: ...
def get(group_name: str, service_name: str, project_name: str, task_name: str) -> ProjectTask: ...
def cancel(group_name: str, service_name: str, project_name: str, task_name: str) -> ProjectTask: ...
def command(group_name: str, service_name: str, project_name: str, task_name: str, parameters: CommandProperties) -> CommandProperties: ...Database connection classes and configuration for various source and target platforms including SQL Server, MySQL, Oracle, PostgreSQL, and MongoDB.
# Connection info classes
class SqlConnectionInfo(ConnectionInfo): ...
class MySqlConnectionInfo(ConnectionInfo): ...
class PostgreSqlConnectionInfo(ConnectionInfo): ...
class OracleConnectionInfo(ConnectionInfo): ...
class MongoDbConnectionInfo(ConnectionInfo): ...Specialized task property classes for different migration scenarios, validation operations, and database-specific migration workflows.
# SQL Server migration tasks
class MigrateSqlServerSqlDbTaskProperties(ProjectTaskProperties): ...
class MigrateSqlServerSqlMITaskProperties(ProjectTaskProperties): ...
# MySQL migration tasks
class MigrateMySqlAzureDbForMySqlOfflineTaskProperties(ProjectTaskProperties): ...
class MigrateMySqlAzureDbForMySqlSyncTaskProperties(ProjectTaskProperties): ...
# Oracle migration tasks
class MigrateOracleAzureDbForPostgreSqlSyncTaskProperties(ProjectTaskProperties): ...Operations for managing project files including migration scripts, configuration files, and other migration assets.
# Key file operations
def create_or_update(group_name: str, service_name: str, project_name: str, file_name: str, parameters: ProjectFile) -> ProjectFile: ...
def get(group_name: str, service_name: str, project_name: str, file_name: str) -> ProjectFile: ...
def read(group_name: str, service_name: str, project_name: str, file_name: str) -> FileStorageInfo: ...Service-level tasks that operate independently of specific projects, including driver management and service-wide operations.
# Key service task operations
def create_or_update(group_name: str, service_name: str, task_name: str, parameters: ProjectTask) -> ProjectTask: ...
def get(group_name: str, service_name: str, task_name: str) -> ProjectTask: ...
def cancel(group_name: str, service_name: str, task_name: str) -> ProjectTask: ...Operations for retrieving resource usage, quotas, available SKUs, and API operation information.
# Resource information operations
def list_skus() -> ItemPaged[ResourceSku]: ... # Available SKUs
def list() -> ItemPaged[Quota]: ... # Usage quotas
def list() -> ItemPaged[ServiceOperation]: ... # Available operationsclass DataMigrationService:
"""Azure Data Migration Service resource."""
def __init__(self, location: str, **kwargs): ...
# Properties
location: str
kind: str
sku: ServiceSku
provisioning_state: str
public_key: str
class Project:
"""Migration project resource."""
def __init__(self, location: str, source_platform: str, target_platform: str, **kwargs): ...
# Properties
location: str
source_platform: str # SQL, MySQL, PostgreSQL, MongoDb, Oracle
target_platform: str # SQLDB, SQLMI, AzureDbForMySql, AzureDbForPostgreSql, MongoDb
source_connection_info: ConnectionInfo
target_connection_info: ConnectionInfo
databases_info: List[DatabaseInfo]
class ProjectTask:
"""Migration or validation task."""
def __init__(self, properties: ProjectTaskProperties, **kwargs): ...
# Properties
etag: str
properties: ProjectTaskProperties
task_type: str
class ProjectTaskProperties:
"""Base class for task properties."""
# Properties
errors: List[ODataError]
state: str # Unknown, Queued, Running, Canceled, Succeeded, Failed, etc.
commands: List[CommandProperties]
client_data: Dict[str, Any]class ConnectionInfo:
"""Base connection information."""
def __init__(self, type: str, **kwargs): ...
# Properties
type: str
user_name: str
password: strclass DataMigrationError:
"""Migration error information."""
message: str
type: str
class ODataError:
"""OData error response."""
code: str
message: str
target: str
details: List[ODataError]
class MigrationValidationResult:
"""Migration validation results."""
id: str
migration_id: str
summary_result: MigrationValidationDatabaseSummaryResult
status: str