0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Azure Data Factory で Execute Pipeline アクティビティを使用して呼び出し先の出力値を取得する方法

Posted at

概要

Azure Data Factory にて Execute Pipeline アクティビティによる呼び出し先の出力値を取得する方法を共有します。変数の設定アクティビティのパイプラインの戻り値を設定することで、呼び出し元(Execute Pipeline アクティビティを含むパイプライン)でその値を利用できます。

image.png

デバック実行した際などには出力される値が表示されませんが、パイプラインの戻り値で指定した名前を利用することで値を取得できました。

@activity('Execute Pipeline1').output.pipelineReturnValue.message

image.png

image.png

検証手順

1. 子のパイプライン(Execute Pipeline アクティビティにより実行されるパイプライン)を作成

変数の設定アクティビティにてパイプラインの戻り値にて、 message という名前に出力したい値(例:失敗アクティビティの出力値)を設定。

パイプライン定義
{
    "name": "child_pipe",
    "properties": {
        "activities": [
            {
                "name": "Fail1",
                "type": "Fail",
                "dependsOn": [],
                "userProperties": [],
                "typeProperties": {
                    "message": {
                        "value": "\"エラーですよ\"",
                        "type": "Expression"
                    },
                    "errorCode": {
                        "value": "\"102\"",
                        "type": "Expression"
                    }
                }
            },
            {
                "name": "Set error_message_copy1",
                "type": "SetVariable",
                "dependsOn": [
                    {
                        "activity": "Fail1",
                        "dependencyConditions": [
                            "Completed"
                        ]
                    }
                ],
                "policy": {
                    "secureOutput": false,
                    "secureInput": false
                },
                "userProperties": [],
                "typeProperties": {
                    "variableName": "pipelineReturnValue",
                    "value": [
                        {
                            "key": "errorCode",
                            "value": {
                                "type": "Expression",
                                "content": "@activity('Fail1').output.errorCode"
                            }
                        },
                        {
                            "key": "message",
                            "value": {
                                "type": "Expression",
                                "content": "@activity('Fail1').output.message"
                            }
                        }
                    ],
                    "setSystemVariable": true
                }
            }
        ],
        "variables": {
            "error_code": {
                "type": "String"
            },
            "error_message": {
                "type": "String"
            }
        },
        "annotations": []
    }
}

image.png

2. 親のパイプライン(Execute Pipeline アクティビティを含むパイプライン)を作成

変数の設定アクティビティにて下記の式を設定。

@activity('Execute Pipeline1').output.pipelineReturnValue.message

パイプライン定義
{
    "name": "parent_pipe",
    "properties": {
        "activities": [
            {
                "name": "Execute Pipeline1",
                "type": "ExecutePipeline",
                "dependsOn": [],
                "policy": {
                    "secureInput": false
                },
                "userProperties": [],
                "typeProperties": {
                    "pipeline": {
                        "referenceName": "child_pipe",
                        "type": "PipelineReference"
                    },
                    "waitOnCompletion": true
                }
            },
            {
                "name": "Set variable1",
                "type": "SetVariable",
                "dependsOn": [
                    {
                        "activity": "Execute Pipeline1",
                        "dependencyConditions": [
                            "Succeeded"
                        ]
                    }
                ],
                "policy": {
                    "secureOutput": false,
                    "secureInput": false
                },
                "userProperties": [],
                "typeProperties": {
                    "variableName": "test",
                    "value": {
                        "value": "@activity('Execute Pipeline1').output.pipelineReturnValue.message",
                        "type": "Expression"
                    }
                }
            }
        ],
        "variables": {
            "test": {
                "type": "String"
            }
        },
        "annotations": []
    }
}

image.png

3. デバック実行し正常終了することを確認

image.png

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?