建立跨雲端連線

跨雲端連線是 BigQuery 連線,可將 Amazon Web Services (AWS)、Microsoft Azure 和 Salesforce Data 360 的資料匯入 BigQuery,以供查詢。這些連線是 BigQuery Omni 標準 BigQuery 連線的替代方案,BigQuery 會在遠端區域部署輕量級的運算工作站,讓您查詢其他雲端中的資料,不必移動任何資料。

與標準連線相比,工作負載可透過跨雲端連線獲得以下優勢:

  • 功能一致性。將其他雲端的資料匯入 BigQuery 後,您就能直接存取 BigQuery AI 功能、Gemini Enterprise Agent Platform、具體化檢視區塊、使用者定義函數,以及透過標準連線無法使用的其他功能。
  • 具成本效益。使用跨雲端連線的工作負載會耗用標準時段預留和承諾,因此不需要管理個別的運算容量。
  • 智慧型快取。在跨雲端傳輸資料時,BigQuery 會自動在本地快取片段,避免後續查詢產生高昂的跨雲端輸出費用。詳情請參閱「智慧型快取」。

如果您的工作負載涉及 Apache Iceberg 目錄,或需要跨 BigQuery 以外的引擎查詢,請考慮改用無邊界 Lakehouse 的跨雲端資料存取功能

事前準備

授予 Identity and Access Management 和第三方角色,讓使用者具備執行本文中各項工作所需的權限。

必要的 BigQuery 角色

如要取得建立跨雲端連線所需的權限,請要求管理員授予您專案的 BigQuery 管理員 (roles/bigquery.admin) IAM 角色。如要進一步瞭解如何授予角色,請參閱「管理專案、資料夾和組織的存取權」。

您或許也能透過自訂角色或其他預先定義的角色,取得必要權限。

必要的第三方角色

如要取得建立跨雲端連線所需的權限,請確認您具備下列第三方角色:

  • AWS:可讓您在 AWS 帳戶中建立 IAM 政策和角色的角色。
  • 適用於 Azure:可讓您在 Microsoft Entra ID (Azure AD) 中管理應用程式註冊,並在目標 Azure 帳戶中指派角色的角色,例如「儲存體 Blob 資料讀取者」。

建立 AWS 跨雲端連線

如要建立 AWS 跨雲端連線,請按照下列步驟操作:

  1. 為 BigQuery 建立 AWS IAM 政策,就像建立標準 BigQuery 連線一樣。
  2. 為 BigQuery 建立 AWS IAM 角色,就像建立標準 BigQuery 連線一樣。
  3. 如要建立連線資源,請使用 bq mk --connection 指令

    bq mk --connection \
        --connection_type='AWS' \
        --location=LOCATION \
        --project_id=PROJECT_ID \
        --properties='{"accessRole":{"iamRoleId":"arn:aws:iam::AWS_ACCOUNT_ID:role/ROLE_NAME"}}' \
        CONNECTION_ID

    更改下列內容:

    • LOCATION:標準的 BigQuery 位置,而非 BigQuery Omni 位置。如需選取區域的指引,請參閱「區域建議」。
    • PROJECT_ID:專案的 ID。 Google Cloud
    • AWS_ACCOUNT_ID:上一個步驟中的 AWS IAM 使用者 ID。
    • ROLE_NAME:您選擇的 AWS 角色政策名稱。
    • CONNECTION_ID:要提供給這個連線資源的 ID。
  4. 如要記下服務帳戶資訊,請使用 bq show 指令

    bq show --connection \
        --location=LOCATION \
        PROJECT_ID.LOCATION.CONNECTION_ID
  5. 為 AWS 角色新增信任政策,使用服務帳戶資訊,就像處理標準 BigQuery 連線一樣。

建立 AWS 跨雲端連線後,您現在可以建立資料表和資料集,查詢遠端資料。

AWS 範例

以下範例會建立外部資料表,透過跨雲端連線直接從 Amazon Simple Storage Service (Amazon S3) bucket 查詢 Parquet 檔案:

CREATE SCHEMA `my-project.aws_raw_data`
  OPTIONS (
    location = 'us-east4');

CREATE EXTERNAL TABLE `my-project.aws_raw_data.sales_parquet`
WITH CONNECTION `us-east4.my-aws-connection`
  OPTIONS (
    format = 'PARQUET',
    uris = ['s3://my-data-bucket/sales/year=2025/*']);

下列範例使用 AWS Glue 和跨雲端連線,將整個資料庫聯合至 BigQuery:

CREATE EXTERNAL SCHEMA `my-project.aws_glue_data`
WITH CONNECTION `us-east4.my-aws-connection`
  OPTIONS (
    location = 'us-east4',
    external_source = 'aws-glue://arn:aws:glue:us-east-4:123456789:database/test_database');

如要進一步瞭解 AWS Glue 聯盟,請參閱「建立及管理 AWS Glue 聯合資料集」。

建立 Azure 跨雲端連線

如要建立 Azure 跨雲端連線,請按照下列步驟操作:

  1. 在 Azure 用戶群中建立應用程式,就像建立標準 BigQuery 連線一樣,並記下應用程式 (用戶端) 和目錄 (租戶) ID。
  2. 將角色指派給 Azure 應用程式,就像指派給標準 BigQuery 連線一樣。
  3. 如要建立連線資源,請使用 bq mk --connection 指令

    bq mk --connection \
        --connection_type='Azure' \
        --tenant_id=TENANT_ID \
        --location=LOCATION \
        --federated_azure=true \
        --federated_app_client_id=APP_ID \
        --project_id=PROJECT_ID \
        CONNECTION_ID

    更改下列內容:

    • TENANT_ID:包含 Azure 帳戶的 Azure 目錄的租戶 ID。
    • LOCATION:標準的 BigQuery 位置,而非 BigQuery Omni 位置。如需選取區域的指引,請參閱「區域建議」。
    • APP_ID:Azure 應用程式 (用戶端) ID。
    • PROJECT_ID:專案的 ID。 Google Cloud
    • CONNECTION_ID:要提供給這個連線資源的 ID。
  4. 如要記下服務帳戶資訊,請使用 bq show 指令

    bq show --connection \
        --location=LOCATION \
        PROJECT_ID.LOCATION.CONNECTION_ID
  5. 使用服務帳戶資訊新增同盟憑證,就像新增標準 BigQuery 連線一樣。

建立 Azure 跨雲端連線後,您現在可以建立資料表和資料集,查詢遠端資料。

Azure 範例

以下範例會建立外部資料表,直接從 Azure Blob 儲存體容器查詢 Parquet 檔案,並使用跨雲端連線:

CREATE SCHEMA `my-project.azure_raw_data`
  OPTIONS (
    location = 'us-east4');

CREATE EXTERNAL TABLE `my-project.azure_raw_data.sales_parquet`
WITH CONNECTION `us-east4.my-azure-connection`
  OPTIONS (
    format = 'PARQUET',
    uris = ['azure://mystorageaccount.blob.core.windows.net/mycontainer/sales/year=2025/*']);

下列範例會建立外部資料表,透過跨雲端連線查詢 Blob 儲存體容器中的原始 CSV 匯出內容:

CREATE EXTERNAL TABLE `my-project.azure_raw_data.daily_logs_csv`
WITH CONNECTION `us-east4.my-azure-connection`
  OPTIONS (
    format = 'CSV',
    skip_leading_rows = 1,
    uris = ['azure://mystorageaccount.blob.core.windows.net/mycontainer/logs/*.csv']);

建立 Data 360 跨雲端連線

如要建立 Data 360 跨雲端連結,請按照將 Data 360 資料集連結至 BigQuery 的步驟操作,但請在標準 BigQuery 位置建立連結的資料集,而非在 BigQuery Omni 位置建立。如需選取區域的指引,請參閱「區域建議」。

將查詢更新為使用新資料集後,即可刪除所有舊版連結資料集和 BigQuery Omni 具體化檢視區塊。

區域建議

為跨雲端連線選取標準 BigQuery 區域時,請選擇與資料實際位置最接近的區域,以獲得最佳成本和效能效率。

下表列出 AWS 區域和最合適的對應 BigQuery 區域:

AWS 區域 最接近的 BigQuery 區域 其他鄰近的 BigQuery 區域
us-east-1 us-east4 us-east1
us-east5
us-central1
us-east-2 us-east5 us-east4
us-east1
us-central1
us-west-1 us-west2 us-west4
us-west1
us-west3
us-west-2 us-west1 us-west3
us-west4
us-west2
ca-central-1 northamerica-northeast1 northamerica-northeast2
us-east4
us-east5
sa-east-1 southamerica-east1 southamerica-west1
us-east1
us-south1
eu-west-1 europe-west1 europe-west2
europe-west9
europe-west4
eu-west-2 europe-west2 europe-west1
europe-west9
europe-west4
eu-west-3 europe-west9 europe-west1
europe-west2
europe-west3
eu-central-1 europe-west3 europe-west4
europe-west1
europe-west6
eu-central-2 europe-west6 europe-west8
europe-west12
europe-west3
eu-north-1 europe-north1 europe-west4
europe-central2
europe-west1
eu-south-1 europe-west8 europe-west12
europe-west6
europe-west3
eu-south-2 europe-southwest1 europe-west9
europe-west1
europe-west8
me-central-1 me-central1 me-central2
me-west1
asia-south1
me-south-1 me-central2 me-central1
me-west1
asia-south1
af-south-1 europe-southwest1 me-central2
me-west1
europe-west1
ap-east-1 asia-east2 asia-east1
asia-southeast1
asia-northeast1
ap-northeast-1 asia-northeast1 asia-northeast2
asia-northeast3
asia-east1
ap-northeast-2 asia-northeast3 asia-northeast2
asia-northeast1
asia-east1
ap-northeast-3 asia-northeast2 asia-northeast1
asia-northeast3
asia-east1
ap-south-1 asia-south1 asia-south2
me-central1
asia-southeast1
ap-south-2 asia-south2 asia-south1
asia-southeast1
me-central1
ap-southeast-1 asia-southeast1 asia-southeast2
asia-east1
asia-south1
ap-southeast-2 australia-southeast1 australia-southeast2
asia-southeast2
asia-southeast1
ap-southeast-3 asia-southeast2 asia-southeast1
australia-southeast1
asia-east1

下表列出 Azure 區域,以及最適合的對應 BigQuery 區域:

Azure 區域 最接近的 BigQuery 區域 其他鄰近的 BigQuery 區域
美國東部 us-east4 us-east1
us-east5
us-central1
美國東部 2 us-east4 us-east1
us-east5
us-south1
美國西部 us-west1 us-west2
us-west3
us-west4
美國西部 2 us-west1 us-west4
us-west3
us-west2
美國西部 3 us-west4 us-west2
us-west3
us-west1
美國中部 us-central1 us-east5
us-east4
us-east1
美國中北部 us-east5 us-central1
us-east4
us-east1
美國中南部 us-south1 us-east5
us-central1
us-east1
美國中西部 us-west3 us-central1
us-west4
us-west2
加拿大中部 northamerica-northeast2 northamerica-northeast1
us-east5
us-east4
加拿大東部 northamerica-northeast1 northamerica-northeast2
us-east4
us-east5
西歐 europe-west4 europe-west1
europe-west3
europe-west9
北歐 europe-west1 europe-west2
europe-west9
europe-west4
法國中部 europe-west9 europe-west1
europe-west2
europe-west3
法國南部 europe-west9 europe-southwest1
europe-west8
europe-west1
德國中西部 europe-west3 europe-west4
europe-west1
europe-west6
德國北部 europe-west3 europe-west4
europe-central2
europe-west2
瑞士北部 europe-west6 europe-west8
europe-west12
europe-west3
瑞士西部 europe-west6 europe-west9
europe-west8
europe-west3
英國南部 europe-west2 europe-west1
europe-west9
europe-west4
英國西部 europe-west2 europe-west1
europe-west9
europe-west4
挪威東部 europe-north1 europe-west4
europe-central2
europe-west1
挪威西部 europe-north1 europe-west4
europe-central2
europe-west1
瑞典中部 europe-north1 europe-west4
europe-central2
europe-west1
東亞 asia-east2 asia-east1
asia-southeast1
asia-northeast1
東南亞 asia-southeast1 asia-southeast2
asia-east1
asia-south1
日本東部 asia-northeast1 asia-northeast2
asia-northeast3
asia-east1
日本西部 asia-northeast2 asia-northeast1
asia-northeast3
asia-east1
韓國中部 asia-northeast3 asia-northeast2
asia-northeast1
asia-east1
澳洲東部 australia-southeast1 australia-southeast2
asia-southeast2
asia-southeast1
澳洲東南 australia-southeast2 australia-southeast1
asia-southeast1
asia-east1
澳洲中部 australia-southeast1 australia-southeast2
asia-southeast2
asia-southeast1
西印度 asia-south1 asia-south2
me-central1
asia-southeast1
印度中部 asia-south1 asia-south2
me-central1
asia-southeast1
印度南部 asia-south1 asia-south2
asia-southeast1
me-central1

後續步驟