Share via


ワークフロー オーケストレーション マネージャーで GitHub リポジトリを同期する

適用対象: Azure Data Factory Azure Synapse Analytics

ヒント

企業向けのオールインワン分析ソリューション、Microsoft Fabric の Data Factory をお試しください。 Microsoft Fabric は、データ移動からデータ サイエンス、リアルタイム分析、ビジネス インテリジェンス、レポートまで、あらゆるものをカバーしています。 無料で新しい試用版を開始する方法について説明します。

Note

ワークフロー オーケストレーション マネージャーは Apache Airflow を利用しています。

この記事では、Azure Data Factory ワークフロー オーケストレーション マネージャーで GitHub リポジトリを 2 つの異なる方法で同期する方法について説明します:

  • ワークフロー オーケストレーション マネージャー UI で [Git 同期を有効にする] を使用します。
  • REST API を使用します。

前提条件

ワークフロー オーケストレーション マネージャー UI の使用

ワークフロー オーケストレーション マネージャー UI を使用して GitHub リポジトリを同期するには:

  1. リポジトリに必要なフォルダーとファイルが含まれていることを確認します:

    • dags/: Apache Airflow 有向非循環グラフ (DAG) の場合 (必須)。

    • Plugins/: 外部機能を Airflow に統合する場合。

      GitHub の Airflow フォルダー構造を示すスクリーンショット。

  2. ワークフロー オーケストレーション マネージャー統合ランタイムを作成するときに、[Airflow 環境のセットアップ] ダイアログで [Git 同期を有効にする] を選択します。

    Airflow 統合ランタイムの作成時に表示される [Airflow 環境のセットアップ] ダイアログの [Git 同期を有効にする] チェックボックスを示すスクリーンショット。

  3. 以下のサポートされている Git サービスの種類のいずれかを選択します:

    • GitHub
    • ADO
    • GitLab
    • BitBucket

    ワークフロー オーケストレーション マネージャー統合ランタイムの作成時に表示される環境セットアップ ダイアログの [Git サービスの種類の選択] ドロップダウンを示すスクリーンショット。

  4. 資格情報の種類を選択:

    • None (パブリック リポジトリ用): このオプションを選択する場合は、リポジトリの可視性がパブリックになっていることを確認してください。 次に、詳細を入力します:

      • Git リポジトリの URL (必須): 目的の GitHub リポジトリの複製 URL。
      • Git ブランチ (必須): 必要な Git リポジトリがある現在のブランチ。
    • Git 個人用アクセス トークン: 個人用アクセス トークン (PAT) に対してこのオプションを選択した後、選択した Git サービスの種類に基づいて残りのフィールドに入力します:

      • GitHub の個人用アクセス トークン
      • ADO 個人用アクセス トークン
      • GitLab 個人用アクセス トークン
      • BitBucket 個人用アクセス トークン

      ワークフロー オーケストレーション マネージャー統合ランタイムの作成時に表示される[Airflow 環境のセットアップ] ダイアログの Git PAT 資格情報オプションを示すスクリーンショット。

    • SPN (サービス プリンシパル名): この資格情報の種類は ADO でのみサポートされます。 このオプションを選択したら、選択した Git サービスの種類に基づいて残りのフィールドに入力します:

      • Git リポジトリ URL (必須): 同期する Git リポジトリへの複製 URL。
      • Git ブランチ (必須): 同期するリポジトリのブランチ。
      • サービス プリンシパル アプリ ID (必須): 同期する ADO リポジトリへのアクセス権を持つサービス プリンシパル アプリ ID。
      • サービス プリンシパル シークレット (必須): ADO リポジトリの認証とアクセスに使用される値を持つ、サービス プリンシパルで手動で生成されたシークレット。
      • サービス プリンシパル テナント ID (必須): サービス プリンシパル テナント ID。

      ワークフロー オーケストレーション マネージャー統合ランタイムの作成時に表示される [Airflow 環境のセットアップ] ダイアログの Git SPN 資格情報オプションを示すスクリーンショット。

  5. 残りのフィールドに必要な情報を入力します。

  6. [作成] を選択します

REST API を使用する

Rest API を使用して GitHub リポジトリを同期するには:

  • メソッド: PUT

  • URL: https://management.azure.com/subscriptions/<subscriptionid>/resourcegroups/<resourceGroupName>/providers/Microsoft.DataFactory/factories/<datafactoryName>/integrationruntimes/<airflowEnvName>?api-version=2018-06-01

  • URI パラメーター:

    名前 / 必須 タイプ 説明
    サブスクリプション ID path True string サブスクリプション識別子
    ResourceGroup 名 path True string リソース グループ名 (正規表現パターン: ^[-\w\._\(\)]+$)
    dataFactoryName path True string Azure Data Factory の名前 (正規表現パターン: ^[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*$
    airflowEnvName path True string ワークフロー オーケストレーション マネージャー環境の名前
    API バージョン query string API のバージョン
  • 要求本文 (Airflow 構成):

    名前 種類 説明
    name string Airflow 環境の名前
    properties propertyType 環境の構成プロパティ
  • プロパティの型:

    名前 種類 説明
    Type string リソースの種類 (このシナリオでは Airflow)
    typeProperties typeProperty エアフロー
  • Type プロパティ:

    名前 種類 説明
    computeProperties computeProperty 環境に使われたコンピューティングの種類の構成
    airflowProperties airflowProperty 環境の Airflow プロパティの構成
  • コンピューティング プロパティ:

    名前 種類 Description
    location string Airflow 統合ランタイムの場所は、既定でデータ ファクトリのリージョンに設定されます。 別のリージョンに統合ランタイムを作成するには、必要なリージョンに新しいデータ ファクトリを作成します。
    computeSize string ご利用の Airflow 環境を実行する計算ノードのサイズ。 たとえば、Large または Small です。 最初に 3 つのノードが割り当てられます。
    extraNodes integer 追加ノードごとに、さらに 3 つのワーカーが追加されます。
  • Airflow プロパティ:

    名前 種類 説明
    airflowVersion string サポートされているバージョンの Apache Airflow。 たとえば、2.4.3 です。
    airflowRequirements Array<string> 使用する Python ライブラリ。 たとえば、["flask-bcrypy=0.7.1"] です。 コンマ区切りのリストを指定できます。
    airflowEnvironmentVariables オブジェクト (キーと値のペア) 使用する環境変数。 たとえば、{ "SAMPLE_ENV_NAME": "test" } です。
    gitSyncProperties gitSyncProperty Git 構成プロパティ。
    enableAADIntegration boolean Microsoft Entra ID がワークフロー オーケストレーション マネージャーにログインできるようにします。
    userName 文字列または null 値 Basic 認証のユーザー名。
    password 文字列または null 値 Basic 認証のパスワード。
  • Git 同期プロパティ:

    名前 種類 説明
    gitServiceType string 目的のリポジトリが配置されている Git サービス。 値は、GitHub、ADO、GitLab、または BitBucket です。
    gitCredentialType string Git 資格情報の種類。 値は PAT (個人用アクセス トークンの場合)、SPN (ADO でのみサポート)、None です。
    レポジトリ string リポジトリ リンク。
    分岐 string リポジトリで使うブランチ。
    username string GitHub ユーザー名。
    資格情報 string PAT の値。
    tenantId string サービス プリンシパル テナント ID (ADO でのみサポート)。
  • 応答:

    名前 状態コード 説明
    同意 200 ファクトリ OK
    権限がありません 401 クラウド エラー エラーの詳細を含む配列

次の例を確認してください。

要求のサンプル:

HTTP
PUT https://management.azure.com/subscriptions/222f1459-6ebd-4896-82ab-652d5f6883cf/resourcegroups/abnarain-rg/providers/Microsoft.DataFactory/factories/ambika-df/integrationruntimes/sample-2?api-version=2018-06-01

サンプル本文:

{
   "name": "sample-2",
   "properties": {
      "type": "Airflow",
      "typeProperties": {
         "computeProperties": {
            "location": "East US",
            "computeSize": "Large",
            "extraNodes": 0
         },
         "airflowProperties": {
            "airflowVersion": "2.4.3",
            "airflowEnvironmentVariables": {
               "AIRFLOW__TEST__TEST": "test"
            },
            "airflowRequirements": [
               "apache-airflow-providers-microsoft-azure"
            ],
            "enableAADIntegration": true,
            "userName": null,
            "password": null,
            "airflowEntityReferences": []
         }
      }
   }
}

サンプル応答

Status code: 200 OK

応答本文:

{
   "id": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/your-rg/providers/Microsoft.DataFactory/factories/your-df/integrationruntimes/sample-2",
   "name": "sample-2",
   "type": "Microsoft.DataFactory/factories/integrationruntimes",
   "properties": {
      "type": "Airflow",
      "typeProperties": {
         "computeProperties": {
            "location": "East US",
            "computeSize": "Large",
            "extraNodes": 0
         },
         "airflowProperties": {
            "airflowVersion": "2.4.3",
            "pythonVersion": "3.8",
            "airflowEnvironmentVariables": {
               "AIRFLOW__TEST__TEST": "test"
            },
            "airflowWebUrl": "https://e57f7409041692.eastus.airflow.svc.datafactory.azure.com/login/",
            "airflowRequirements": [
               "apache-airflow-providers-microsoft-azure"
            ],
            "airflowEntityReferences": [],
            "packageProviderPath": "plugins",
            "enableAADIntegration": true,
            "enableTriggerers": false
         }
      },
      "state": "Initial"
   },
   "etag": "3402279e-0000-0100-0000-64ecb1cb0000"
}

以下に API ペイロードの例をいくつか示します。

  • PAT を使用した GitHub の Git 同期プロパティ:

    "gitSyncProperties":  {
            "gitServiceType": "Github",
            "gitCredentialType": "PAT",
            "repo":  <repo url>,
            "branch": <repo branch to sync>,
            "username": <username>,
            "credential": <personal access token>
    }
    
  • PAT を使用した ADO の Git 同期プロパティ:

    "gitSyncProperties":  {
            "gitServiceType": "ADO",
            "gitCredentialType": "PAT",
            "repo":  <repo url>,
            "branch": <repo branch to sync>,
            "username": <username>,
            "credential": <personal access token>
    }
    
  • サービス プリンシパルを使用した ADO の Git 同期プロパティ:

    "gitSyncProperties":  {
            "gitServiceType": "ADO",
            "gitCredentialType": "SPN",
            "repo":  <repo url>,
            "branch": <repo branch to sync>,
            "username": < service principal app id >,
            "credential": <service principal secret value>
            "tenantId": <service principal tenant id>
    }
    
  • GitHub パブリック リポジトリの Git 同期プロパティ:

    "gitSyncProperties":  {
            "gitServiceType": "Github",
            "gitCredentialType": "None",
            "repo":  <repo url>,
            "branch": <repo branch to sync>
    }
    

Git 同期を使用してプライベート パッケージをインポートする

このオプションのプロセスは、プライベート パッケージを使用する場合にのみ適用されます。

このプロセスでは、プライベート パッケージが Git 同期によって自動同期されたことを前提としています。ADO リポジトリに接続している場合は、ワークフロー オーケストレーション マネージャー UI でパス プレフィックス /opt/airflow/git/\<repoName\>/ と共にパッケージを要件として追加します。 他のすべての Git サービスには /opt/airflow/git/\<repoName\>.git/ を使用します。

たとえば、プライベート パッケージが GitHub リポジトリの /dags/test/private.whl にある場合は、ワークフロー オーケストレーション マネージャー環境に要件 /opt/airflow/git/\<repoName\>.git/dags/test/private.whl を追加する必要があります。

ワークフロー オーケストレーション マネージャー統合ランタイムの作成時に表示される [Airflow 環境のセットアップ] ダイアログの [Airflow 要件] セクションを示すスクリーンショット。