使用 Azure 数据工厂从 Google BigQuery 复制数据Copy data from Google BigQuery by using Azure Data Factory

适用于: Azure 数据工厂 Azure Synapse Analytics(预览版)

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

支持的功能Supported capabilities

以下活动支持此 Google BigQuery 连接器:This Google BigQuery connector is supported for the following activities:

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

数据工厂提供内置驱动程序以启用连接。Data Factory provides a built-in driver to enable connectivity. 因此,无需要手动安装驱动程序即可使用此连接器。Therefore, you don't need to manually install a driver to use this connector.

备注

此 Google BigQuery 连接器在 BigQuery API 的基础上构建。This Google BigQuery connector is built on top of the BigQuery APIs. 请注意,BigQuery 会限制传入请求的最大速率并按项目强制实施适当的配额,请参阅配额和限制 - API 请求Be aware that BigQuery limits the maximum rate of incoming requests and enforces appropriate quotas on a per-project basis, refer to Quotas & Limits - API requests. 请确保不会触发过多的帐户并发请求。Make sure you do not trigger too many concurrent requests to the account.

入门Get started

若要使用管道执行复制活动,可以使用以下工具或 SDK 之一:To perform the Copy activity with a pipeline, you can use one of the following tools or SDKs:

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

链接服务属性Linked service properties

Google BigQuery 链接服务支持以下属性。The following properties are supported for the Google BigQuery linked service.

属性Property 说明Description 必须Required
typetype type 属性必须设置为 GoogleBigQueryThe type property must be set to GoogleBigQuery. Yes
projectproject 针对其查询的默认 BigQuery 项目的项目 ID。The project ID of the default BigQuery project to query against. Yes
additionalProjectsadditionalProjects 要访问的公共 BigQuery 项目的项目 ID 逗号分隔列表。A comma-separated list of project IDs of public BigQuery projects to access. No
requestGoogleDriveScoperequestGoogleDriveScope 是否要请求访问 Google Drive。Whether to request access to Google Drive. 允许 Google Drive 访问可支持将 BigQuery 数据与 Google Drive 中的数据组合的联合表。Allowing Google Drive access enables support for federated tables that combine BigQuery data with data from Google Drive. 默认值是 false秒。The default value is false. No
authenticationTypeauthenticationType 用于身份验证的 OAuth 2.0 身份验证机制。The OAuth 2.0 authentication mechanism used for authentication. ServiceAuthentication 只能在自承载集成运行时上使用。ServiceAuthentication can be used only on Self-hosted Integration Runtime.
允许的值为 UserAuthenticationServiceAuthenticationAllowed values are UserAuthentication and ServiceAuthentication. 有关这些身份验证类型的其他属性和 JSON 示例,请分别参阅此表格下面的部分。Refer to sections below this table on more properties and JSON samples for those authentication types respectively.
Yes

使用用户身份验证Using user authentication

将“authenticationType”属性设置为“UserAuthentication” ,并指定以下属性及上节所述的泛型属性:Set "authenticationType" property to UserAuthentication, and specify the following properties along with generic properties described in the previous section:

属性Property 说明Description 必须Required
clientIdclientId 应用程序的 ID,用于生成刷新令牌。ID of the application used to generate the refresh token. No
clientSecretclientSecret 应用程序的机密,用于生成刷新令牌。Secret of the application used to generate the refresh token. 将此字段标记为 SecureString 以安全地将其存储在数据工厂中或引用存储在 Azure Key Vault 中的机密Mark this field as a SecureString to store it securely in Data Factory, or reference a secret stored in Azure Key Vault. No
refreshTokenrefreshToken 从 Google 获得的刷新令牌,用于授权访问 BigQuery。The refresh token obtained from Google used to authorize access to BigQuery. 获取 OAuth 2.0 访问令牌此社区博客了解如何获取刷新令牌。Learn how to get one from Obtaining OAuth 2.0 access tokens and this community blog. 将此字段标记为 SecureString 以安全地将其存储在数据工厂中或引用存储在 Azure Key Vault 中的机密Mark this field as a SecureString to store it securely in Data Factory, or reference a secret stored in Azure Key Vault. No

示例:Example:

{
    "name": "GoogleBigQueryLinkedService",
    "properties": {
        "type": "GoogleBigQuery",
        "typeProperties": {
            "project" : "<project ID>",
            "additionalProjects" : "<additional project IDs>",
            "requestGoogleDriveScope" : true,
            "authenticationType" : "UserAuthentication",
            "clientId": "<id of the application used to generate the refresh token>",
            "clientSecret": {
                "type": "SecureString",
                "value":"<secret of the application used to generate the refresh token>"
            },
            "refreshToken": {
                "type": "SecureString",
                "value": "<refresh token>"
            }
        }
    }
}

使用服务身份验证Using service authentication

将“authenticationType”属性设置为“ServiceAuthentication” ,并指定以下属性及上节所述的泛型属性。Set "authenticationType" property to ServiceAuthentication, and specify the following properties along with generic properties described in the previous section. 此身份验证类型只能在自承载 Integration Runtime 上使用。This authentication type can be used only on Self-hosted Integration Runtime.

属性Property 说明Description 必须Required
电子邮件email 用于 ServiceAuthentication 的服务帐户电子邮件 ID。The service account email ID that is used for ServiceAuthentication. 它只能在自承载集成运行时上使用。It can be used only on Self-hosted Integration Runtime. No
keyFilePathkeyFilePath .p12 密钥文件的完整路径,该文件用于对服务帐户电子邮件地址进行身份验证。The full path to the .p12 key file that is used to authenticate the service account email address. No
trustedCertPathtrustedCertPath 包含受信任 CA 证书(通过 TLS 进行连接时用来验证服务器)的 .pem 文件的完整路径。The full path of the .pem file that contains trusted CA certificates used to verify the server when you connect over TLS. 仅当在自承载集成运行时上使用 TLS 时,才能设置此属性。This property can be set only when you use TLS on Self-hosted Integration Runtime. 默认值是随集成运行时一起安装的 cacerts.pem 文件。The default value is the cacerts.pem file installed with the integration runtime. No
useSystemTrustStoreuseSystemTrustStore 指定是使用系统信任存储中的 CA 证书还是使用指定 .pem 文件中的 CA 证书。Specifies whether to use a CA certificate from the system trust store or from a specified .pem file. 默认值是 false秒。The default value is false. No

示例:Example:

{
    "name": "GoogleBigQueryLinkedService",
    "properties": {
        "type": "GoogleBigQuery",
        "typeProperties": {
            "project" : "<project id>",
            "requestGoogleDriveScope" : true,
            "authenticationType" : "ServiceAuthentication",
            "email": "<email>",
            "keyFilePath": "<.p12 key path on the IR machine>"
        },
        "connectVia": {
            "referenceName": "<name of Self-hosted Integration Runtime>",
            "type": "IntegrationRuntimeReference"
        }
    }
}

数据集属性Dataset properties

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

要从 Google BigQuery 复制数据,请将数据集的 type 属性设置为 GoogleBigQueryObjectTo copy data from Google BigQuery, set the type property of the dataset to GoogleBigQueryObject. 支持以下属性:The following properties are supported:

属性Property 说明Description 必须Required
typetype 数据集的 type 属性必须设置为:GoogleBigQueryObjectThe type property of the dataset must be set to: GoogleBigQueryObject Yes
datasetdataset Google BigQuery 数据集的名称。Name of the Google BigQuery dataset. 否(如果指定了活动源中的“query”)No (if "query" in activity source is specified)
table 表的名称。Name of the table. 否(如果指定了活动源中的“query”)No (if "query" in activity source is specified)
tableNametableName 表的名称。Name of the table. 支持此属性是为了向后兼容。This property is supported for backward compatibility. 对于新的工作负荷,请使用 datasettableFor new workload, use dataset and table. 否(如果指定了活动源中的“query”)No (if "query" in activity source is specified)

示例Example

{
    "name": "GoogleBigQueryDataset",
    "properties": {
        "type": "GoogleBigQueryObject",
        "typeProperties": {},
        "schema": [],
        "linkedServiceName": {
            "referenceName": "<GoogleBigQuery linked service name>",
            "type": "LinkedServiceReference"
        }
    }
}

复制活动属性Copy activity properties

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

以 GoogleBigQuerySource 作为源类型GoogleBigQuerySource as a source type

要从 Google BigQuery 复制数据,请将复制活动中的源类型设置为“GoogleBigQuerySource” 。To copy data from Google BigQuery, set the source type in the copy activity to GoogleBigQuerySource. 复制活动的 source 节支持以下属性。The following properties are supported in the copy activity source section.

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

示例:Example:

"activities":[
    {
        "name": "CopyFromGoogleBigQuery",
        "type": "Copy",
        "inputs": [
            {
                "referenceName": "<GoogleBigQuery input dataset name>",
                "type": "DatasetReference"
            }
        ],
        "outputs": [
            {
                "referenceName": "<output dataset name>",
                "type": "DatasetReference"
            }
        ],
        "typeProperties": {
            "source": {
                "type": "GoogleBigQuerySource",
                "query": "SELECT * FROM MyTable"
            },
            "sink": {
                "type": "<sink type>"
            }
        }
    }
]

Lookup 活动属性Lookup activity properties

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

后续步骤Next steps

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