CtrlK
CommunityDocumentationLog inGet started
Tessl Logo

tessl/pypi-azure-mgmt-datamigration

Microsoft Azure Data Migration Client Library for Python providing comprehensive database migration management capabilities

Overview
Eval results
Files

projects.mddocs/

Migration Projects

Management of migration projects which define the source and target platforms, connection details, and serve as containers for migration tasks. Projects organize and configure the overall migration scenario.

Capabilities

Project Lifecycle Management

Create, update, delete, and retrieve migration projects with source and target platform configuration.

def create_or_update(
    group_name: str,
    service_name: str,
    project_name: str,
    parameters: Project,
    **kwargs
) -> Project:
    """
    Create or update 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 parameters
    
    Returns:
    Project instance details
    """

def get(
    group_name: str,
    service_name: str,
    project_name: str,
    **kwargs
) -> Project:
    """
    Get details of 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 instance details
    """

def delete(
    group_name: str,
    service_name: str,
    project_name: str,
    delete_running_tasks: bool = None,
    **kwargs
) -> None:
    """
    Delete 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
    """

def update(
    group_name: str,
    service_name: str,
    project_name: str,
    parameters: Project,
    **kwargs
) -> Project:
    """
    Update an existing 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 parameters
    
    Returns:
    Updated project details
    """

Project Discovery

List migration projects within a Data Migration Service for inventory and management purposes.

def list(
    group_name: str,
    service_name: str,
    **kwargs
) -> ItemPaged[Project]:
    """
    List migration projects in a Data Migration Service.
    
    Parameters:
    - group_name: Name of the resource group
    - service_name: Name of the Data Migration Service
    
    Returns:
    Paginated list of projects
    """

Usage Examples

Creating a SQL Server to Azure SQL Database Project

from azure.mgmt.datamigration import DataMigrationManagementClient
from azure.mgmt.datamigration.models import (
    Project, SqlConnectionInfo, 
    ProjectSourcePlatform, ProjectTargetPlatform
)
from azure.identity import DefaultAzureCredential

credential = DefaultAzureCredential()
client = DataMigrationManagementClient(credential, "subscription-id")

# Configure source connection (SQL Server)
source_connection = SqlConnectionInfo(
    user_name="source_user",
    password="source_password",
    server_name="source-server.database.windows.net",
    database_name="SourceDB",
    authentication="SqlAuthentication",
    encrypt_connection=True,
    trust_server_certificate=False
)

# Configure target connection (Azure SQL Database)
target_connection = SqlConnectionInfo(
    user_name="target_user", 
    password="target_password",
    server_name="target-server.database.windows.net",
    database_name="TargetDB",
    authentication="SqlAuthentication",
    encrypt_connection=True,
    trust_server_certificate=False
)

# Create project
project = Project(
    location="East US",
    source_platform=ProjectSourcePlatform.SQL,
    target_platform=ProjectTargetPlatform.SQLDB,
    source_connection_info=source_connection,
    target_connection_info=target_connection
)

# Create the project
created_project = client.projects.create_or_update(
    group_name="my-rg",
    service_name="my-migration-service", 
    project_name="sql-to-sqldb-project",
    parameters=project
)

print(f"Project created: {created_project.name}")
print(f"Source platform: {created_project.source_platform}")
print(f"Target platform: {created_project.target_platform}")

Creating a MongoDB to Cosmos DB Project

from azure.mgmt.datamigration.models import MongoDbConnectionInfo

# Configure MongoDB source connection
mongo_source = MongoDbConnectionInfo(
    connection_string="mongodb://username:password@source-cluster:27017/sourcedb"
)

# Configure Cosmos DB target connection  
cosmos_target = MongoDbConnectionInfo(
    connection_string="mongodb://cosmosdb-account:key@cosmosdb-account.mongo.cosmos.azure.com:10255/targetdb?ssl=true"
)

# Create MongoDB project
mongo_project = Project(
    location="East US",
    source_platform=ProjectSourcePlatform.MONGO_DB,
    target_platform=ProjectTargetPlatform.MONGO_DB,
    source_connection_info=mongo_source,
    target_connection_info=cosmos_target
)

# Create the project
mongo_created_project = client.projects.create_or_update(
    group_name="my-rg",
    service_name="my-migration-service",
    project_name="mongo-to-cosmos-project", 
    parameters=mongo_project
)

Listing and Managing Projects

# List all projects in a service
projects = client.projects.list(
    group_name="my-rg",
    service_name="my-migration-service"
)

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}")
    print(f"  Created: {project.creation_time}")

# Update a project
updated_project = client.projects.update(
    group_name="my-rg",
    service_name="my-migration-service",
    project_name="sql-to-sqldb-project",
    parameters=project  # Updated project parameters
)

# Delete a project
client.projects.delete(
    group_name="my-rg", 
    service_name="my-migration-service",
    project_name="sql-to-sqldb-project",
    delete_running_tasks=True
)

Types

class Project:
    """Migration project configuration."""
    name: str
    type: str
    location: str
    source_platform: str  # ProjectSourcePlatform enum
    target_platform: str  # ProjectTargetPlatform enum
    source_connection_info: ConnectionInfo
    target_connection_info: ConnectionInfo
    databases_info: list[DatabaseInfo]
    creation_time: datetime
    provisioning_state: str  # ProjectProvisioningState enum
    etag: str

class ProjectSourcePlatform:
    """Source platform types."""
    SQL = "SQL"
    MYSQL = "MySQL" 
    POSTGRESQL = "PostgreSql"
    MONGO_DB = "MongoDb"
    UNKNOWN = "Unknown"

class ProjectTargetPlatform:
    """Target platform types."""
    SQLDB = "SQLDB"
    SQLMI = "SQLMI"
    AZURE_DB_FOR_MYSQL = "AzureDbForMySql"
    AZURE_DB_FOR_POSTGRESQL = "AzureDbForPostgreSql"
    MONGO_DB = "MongoDb"
    UNKNOWN = "Unknown"

class ProjectProvisioningState:
    """Project provisioning states."""
    DELETING = "Deleting"
    SUCCEEDED = "Succeeded"

class ConnectionInfo:
    """Base class for database connection information."""
    type: str
    user_name: str
    password: str

class SqlConnectionInfo(ConnectionInfo):
    """SQL Server connection information."""
    server_name: str
    port: int
    database_name: str
    authentication: str  # AuthenticationType enum
    encrypt_connection: bool
    trust_server_certificate: bool
    additional_settings: str

class MySqlConnectionInfo(ConnectionInfo):
    """MySQL connection information."""
    server_name: str
    port: int
    database_name: str

class PostgreSqlConnectionInfo(ConnectionInfo):
    """PostgreSQL connection information."""
    server_name: str
    port: int
    database_name: str
    database_name: str

class MongoDbConnectionInfo(ConnectionInfo):
    """MongoDB connection information."""
    connection_string: str

class OracleConnectionInfo(ConnectionInfo):
    """Oracle connection information."""
    server_name: str
    port: int
    service_name: str

class DatabaseInfo:
    """Database information."""
    name: str
tessl i tessl/pypi-azure-mgmt-datamigration@9.0.0

docs

connection-validation.md

files.md

index.md

operations.md

projects.md

resources.md

service-tasks.md

services.md

tasks.md

tile.json