使用 Azure 数据工厂从 Azure Database for MariaDB 复制数据Copy data from Azure Database for MariaDB using Azure Data Factory

本文概述了如何使用 Azure 数据工厂中的复制活动从 Azure Database for MariaDB 复制数据。This article outlines how to use the Copy Activity in Azure Data Factory to copy data from Azure Database for MariaDB. 它是基于概述复制活动总体的复制活动概述一文。It builds on the copy activity overview article that presents a general overview of copy activity.

支持的功能Supported capabilities

可将数据从 Azure Database for MariaDB 复制到任何支持的接收器数据存储。You can copy data from Azure Database for MariaDB to any supported sink data store. 有关复制活动支持作为源/接收器的数据存储列表,请参阅支持的数据存储表。For a list of data stores that are supported as sources/sinks by the copy activity, see the Supported data stores table.

Azure 数据工厂提供内置的驱动程序用于启用连接,因此无需使用此连接器手动安装任何驱动程序。Azure Data Factory provides a built-in driver to enable connectivity, therefore you don't need to manually install any driver using this connector.

入门Getting started

可以通过以下工具或 SDK 之一结合使用复制活动和管道。You can use one of the following tools or SDKs to use the copy activity with a pipeline. 选择链接,查看分步说明:Select a link for step-by-step instructions:

对于特定于 Azure Database for MariaDB 连接器的数据工厂实体,以下部分提供有关用于定义这些实体的属性的详细信息。The following sections provide details about properties that are used to define Data Factory entities specific to Azure Database for MariaDB connector.

链接服务属性Linked service properties

Azure Database for MariaDB 链接服务支持以下属性:The following properties are supported for Azure Database for MariaDB linked service:

属性Property 说明Description 必选Required
typetype type 属性必须设置为:AzureMariaDBThe type property must be set to: AzureMariaDB Yes
connectionStringconnectionString 连接到 Azure Database for MariaDB 的连接字符串。A connection string to connect to Azure Database for MariaDB. 可以从“Azure 门户”->“Azure Database for MariaDB”->“连接字符串”->“ADO.NET”中找到它。You can find it from the Azure portal -> your Azure Database for MariaDB -> Connection strings -> ADO.NET one.
将此字段标记为 SecureString,以便安全地将其存储在数据工厂中。Mark this field as a SecureString to store it securely in Data Factory. 还可以将密码放在 Azure 密钥保管库中,并从连接字符串中拉取 pwd 配置。You can also put password in Azure Key Vault and pull the pwd configuration out of the connection string. 有关更多详细信息,请参阅以下示例和将凭据存储在 Azure 密钥保管库中一文。Refer to the following samples and Store credentials in Azure Key Vault article with more details.
Yes
connectViaconnectVia 用于连接到数据存储的集成运行时The Integration Runtime to be used to connect to the data store. 如果未指定,则使用默认 Azure Integration Runtime。If not specified, it uses the default Azure Integration Runtime. No

示例:Example:

{
    "name": "AzureDatabaseForMariaDBLinkedService",
    "properties": {
        "type": "AzureMariaDB",
        "typeProperties": {
            "connectionString": {
                "type": "SecureString",
                "value": "Server={your_server}.mariadb.database.chinacloudapi.cn; Port=3306; Database={your_database}; Uid={your_user}@{your_server}; Pwd={your_password}; SslMode=Preferred;"
            }
        },
        "connectVia": {
            "referenceName": "<name of Integration Runtime>",
            "type": "IntegrationRuntimeReference"
        }
    }
}

示例:在 Azure 密钥保管库中存储密码Example: store password in Azure Key Vault

{
    "name": "AzureDatabaseForMariaDBLinkedService",
    "properties": {
        "type": "AzureMariaDB",
        "typeProperties": {
            "connectionString": {
                 "type": "SecureString",
                 "value": "Server={your_server}.mariadb.database.chinacloudapi.cn; Port=3306; Database={your_database}; Uid={your_user}@{your_server}; SslMode=Preferred;"
            },
            "pwd": { 
                "type": "AzureKeyVaultSecret", 
                "store": { 
                    "referenceName": "<Azure Key Vault linked service name>", 
                    "type": "LinkedServiceReference" 
                }, 
                "secretName": "<secretName>" 
            }
        },
        "connectVia": {
            "referenceName": "<name of Integration Runtime>",
            "type": "IntegrationRuntimeReference"
        }
    }
}

数据集属性Dataset properties

有关可用于定义数据集的各部分和属性的完整列表,请参阅数据集一文。For a full list of sections and properties available for defining datasets, see the datasets article. 本部分提供 Azure Database for MariaDB 数据集支持的属性列表。This section provides a list of properties supported by Azure Database for MariaDB dataset.

若要从 Azure Database for MariaDB 复制数据,需要支持以下属性:To copy data from Azure Database for MariaDB, the following properties are supported:

属性Property 说明Description 必选Required
typetype 数据集的 type 属性必须设置为:AzureMariaDBTableThe type property of the dataset must be set to: AzureMariaDBTable Yes
tableNametableName 表名称。Name of the table. 否(如果指定了活动源中的“query”)No (if "query" in activity source is specified)

示例Example

{
    "name": "AzureDatabaseForMariaDBDataset",
    "properties": {
        "type": "AzureMariaDBTable",
        "typeProperties": {},
        "schema": [],
        "linkedServiceName": {
            "referenceName": "<Azure Database for MariaDB linked service name>",
            "type": "LinkedServiceReference"
        }
    }
}

复制活动属性Copy activity properties

有关可用于定义活动的各部分和属性的完整列表,请参阅管道一文。For a full list of sections and properties available for defining activities, see the Pipelines article. 本部分提供 Azure Database for MariaDB 源支持的属性列表。This section provides a list of properties supported by Azure Database for MariaDB source.

Azure Database for MariaDB 作为源Azure Database for MariaDB as source

若要从 Azure Database for MariaDB 复制数据,复制活动的 source 节需要支持以下属性:To copy data from Azure Database for MariaDB, the following properties are supported in the copy activity source section:

属性Property 说明Description 必选Required
typetype 复制活动 source 的 type 属性必须设置为:AzureMariaDBSourceThe type property of the copy activity source must be set to: AzureMariaDBSource Yes
queryquery 使用自定义 SQL 查询读取数据。Use the custom SQL query to read data. 例如:"SELECT * FROM MyTable"For example: "SELECT * FROM MyTable". 否(如果指定了数据集中的“tableName”)No (if "tableName" in dataset is specified)

示例:Example:

"activities":[
    {
        "name": "CopyFromAzureDatabaseForMariaDB",
        "type": "Copy",
        "inputs": [
            {
                "referenceName": "<Azure Database for MariaDB input dataset name>",
                "type": "DatasetReference"
            }
        ],
        "outputs": [
            {
                "referenceName": "<output dataset name>",
                "type": "DatasetReference"
            }
        ],
        "typeProperties": {
            "source": {
                "type": "AzureMariaDBSource",
                "query": "SELECT * FROM MyTable"
            },
            "sink": {
                "type": "<sink type>"
            }
        }
    }
]

Lookup 活动属性Lookup activity properties

若要了解有关属性的详细信息,请查看 Lookup 活动To learn details about the properties, check Lookup activity.

后续步骤Next steps

有关 Azure 数据工厂中复制活动支持作为源和接收器的数据存储的列表,请参阅支持的数据存储For a list of data stores supported as sources and sinks by the copy activity in Azure Data Factory, see supported data stores.