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
Operations for managing migration projects within Data Migration services. Projects organize related migration tasks and maintain configuration for source and target database connections, serving as logical containers for migration workflows.
Creates a new migration project or updates an existing one within a Data Migration Service.
def create_or_update(
group_name: str,
service_name: str,
project_name: str,
parameters: Project,
**kwargs
) -> Project:
"""
Creates or updates a migration project.
Parameters:
- group_name: Name of the resource group
- service_name: Name of the Data Migration Service
- project_name: Name of the project
- parameters: Project configuration and properties
Returns:
Project object with current state and configuration
"""Usage Example:
from azure.mgmt.datamigration.models import (
Project,
SqlConnectionInfo,
DatabaseInfo
)
# Configure source connection
source_connection = SqlConnectionInfo(
server_name="source-server.database.windows.net",
database_name="SourceDB",
user_name="sa",
password="password123",
authentication="SqlAuthentication",
encrypt_connection=True,
trust_server_certificate=False
)
# Configure target connection
target_connection = SqlConnectionInfo(
server_name="target-server.database.windows.net",
database_name="TargetDB",
user_name="targetuser",
password="targetpass123",
authentication="SqlAuthentication",
encrypt_connection=True,
trust_server_certificate=False
)
# Create project
project_params = Project(
location="eastus",
source_platform="SQL",
target_platform="SQLDB",
source_connection_info=source_connection,
target_connection_info=target_connection,
databases_info=[
DatabaseInfo(source_database_name="SourceDB")
]
)
project = client.projects.create_or_update(
group_name="myResourceGroup",
service_name="myMigrationService",
project_name="myProject",
parameters=project_params
)
print(f"Project {project.name} created successfully")Retrieves details of an existing migration project.
def get(
group_name: str,
service_name: str,
project_name: str,
**kwargs
) -> Project:
"""
Gets a migration project.
Parameters:
- group_name: Name of the resource group
- service_name: Name of the Data Migration Service
- project_name: Name of the project
Returns:
Project object with current configuration and state
"""Deletes a migration project and all associated tasks and files.
def delete(
group_name: str,
service_name: str,
project_name: str,
delete_running_tasks: Optional[bool] = None,
**kwargs
) -> None:
"""
Deletes a migration project.
Parameters:
- group_name: Name of the resource group
- service_name: Name of the Data Migration Service
- project_name: Name of the project
- delete_running_tasks: Whether to delete running tasks
Returns:
None
"""Updates properties of an existing migration project.
def update(
group_name: str,
service_name: str,
project_name: str,
parameters: Project,
**kwargs
) -> Project:
"""
Updates a migration project.
Parameters:
- group_name: Name of the resource group
- service_name: Name of the Data Migration Service
- project_name: Name of the project
- parameters: Updated project properties
Returns:
Updated Project object
"""Lists all migration projects within a Data Migration Service.
def list(
group_name: str,
service_name: str,
**kwargs
) -> ItemPaged[Project]:
"""
Lists migration projects in a Data Migration Service.
Parameters:
- group_name: Name of the resource group
- service_name: Name of the Data Migration Service
Returns:
Paged collection of Project objects
"""Usage Example:
# List all projects in a service
projects = client.projects.list(
group_name="myResourceGroup",
service_name="myMigrationService"
)
for project in projects:
print(f"Project: {project.name}")
print(f" Source: {project.source_platform}")
print(f" Target: {project.target_platform}")
print(f" State: {project.provisioning_state}")class Project:
"""Migration project resource definition."""
def __init__(
self,
location: str,
source_platform: str,
target_platform: str,
**kwargs
):
"""
Initialize migration project.
Parameters:
- location: Azure region for the project
- source_platform: Source database platform
- target_platform: Target database platform
- source_connection_info: Source database connection
- target_connection_info: Target database connection
- databases_info: List of databases to migrate
"""
# Properties
location: str # Required: Azure region
source_platform: str # Source platform (SQL, MySQL, PostgreSQL, MongoDb, Oracle, Unknown)
target_platform: str # Target platform (SQLDB, SQLMI, AzureDbForMySql, AzureDbForPostgreSql, MongoDb, Unknown)
source_connection_info: ConnectionInfo # Source database connection
target_connection_info: ConnectionInfo # Target database connection
databases_info: List[DatabaseInfo] # Databases to migrate
provisioning_state: str # Current provisioning state
creation_time: datetime # Project creation timestamp
id: str # Resource ID
name: str # Resource name
type: str # Resource type
etag: str # Entity tag for concurrency control
tags: Dict[str, str] # Resource tagsclass DatabaseInfo:
"""Database information for migration."""
def __init__(self, source_database_name: str, **kwargs):
"""
Parameters:
- source_database_name: Name of source database
- target_database_name: Name of target database (optional)
"""
# Properties
source_database_name: str # Required: Source database name
target_database_name: str # Target database name (defaults to source name)
class DatabaseSummaryResult:
"""Database migration summary."""
# Properties
size_mb: float # Database size in MB
name: str # Database name
state: str # Migration state
stage: str # Migration stage
started_on: datetime # Migration start time
ended_on: datetime # Migration end time
message: str # Status message# SQL Server to Azure SQL Database
Project(
source_platform="SQL",
target_platform="SQLDB",
# ... other parameters
)
# MySQL to Azure Database for MySQL
Project(
source_platform="MySQL",
target_platform="AzureDbForMySql",
# ... other parameters
)
# Oracle to Azure Database for PostgreSQL
Project(
source_platform="Oracle",
target_platform="AzureDbForPostgreSql",
# ... other parameters
)
# MongoDB to Azure Cosmos DB
Project(
source_platform="MongoDb",
target_platform="MongoDb",
# ... other parameters
)Project operations may encounter these common issues:
Always validate connection information before creating projects and ensure that the source and target platforms are compatible for your migration scenario.
Install with Tessl CLI
npx tessl i tessl/pypi-azure-mgmt-datamigration