Azure Data Factory 및 Synapse Analytics의 Until 작업

적용 대상: Azure Data Factory Azure Synapse Analytics

기업용 올인원 분석 솔루션인 Microsoft Fabric의 Data Factory를 사용해 보세요. Microsoft Fabric은 데이터 이동부터 데이터 과학, 실시간 분석, 비즈니스 인텔리전스 및 보고에 이르기까지 모든 것을 다룹니다. 무료로 새 평가판을 시작하는 방법을 알아봅니다!

Until 활동은 do-until 루핑 구조가 프로그래밍 언어로 제공하는 것과 동일한 기능을 제공합니다. 작업과 관련된 조건이 참으로 평가될 때까지 일단의 반복 작업을 실행합니다. 내부 작업이 실패하면 Until 작업이 중지되지 않습니다. until 작업의 시간 제한 값을 지정할 수 있습니다.

UI를 사용하여 Until 작업 만들기

파이프라인에서 Until 작업을 사용하려면 다음 단계를 완료합니다.

  1. 파이프라인 활동 창에서 Until을 검색하고 Until 작업을 파이프라인 캔버스로 드래그합니다.

  2. 아직 선택되지 않은 경우 캔버스의 Until 작업과 해당 설정 탭을 선택하여 세부 정보를 편집합니다.

    Shows the Settings tab of the Until activity in the pipeline canvas.

  3. Until 작업에 정의된 모든 자식 활동이 실행된 후에 계산될 식을 입력합니다. 식이 false로 평가되면 Until 작업은 모든 자식 활동을 다시 실행합니다. true로 평가되면 Until 작업이 완료됩니다. 식은 리터럴 문자열 식이거나 동적 식, 함수, 시스템 변수 또는 다른 작업의 출력의 조합일 수 있습니다. 아래 예제에서는 TestVariable이라는 이전에 정의된 파이프라인 배열 변수의 값을 확인하여 ['done']으로 평가되는지 확인합니다.

    Shows the  Add dynamic content  pane with an expression to check a variable for a defined value.

  4. Until 활동에서 직접 [작업 편집] 단추를 선택하거나 [활동] 탭을 선택하여 [작업 때까지] 단추를 선택하여 [Until 작업]이 실행되는 활동을 정의합니다. 새 활동 편집기 창이 표시됩니다. 여기서는 Until 작업이 실행될 활동을 추가할 수 있습니다. 이 예제에서 변수 설정 작업은 afore멘션ed 식에서 참조되는 변수의 값을 ['done']로 설정하므로 Until 활동의 식은 처음 실행될 때 true가 되고 Until 작업은 중지됩니다. 실제 사용에서 필요한 조건을 확인할 수 있으며, 조건이 충족될 때까지 식이 평가될 때마다 Until 작업이 자식 활동을 계속 실행합니다.

    Shows the activities editor for an Until activity with a Set Variable activity defined.

구문

{
    "type": "Until",
    "typeProperties": {
        "expression":  {
            "value":  "<expression that evaluates to true or false>", 
            "type": "Expression"
        },
        "timeout": "<time out for the loop. for example: 00:10:00 (10 minute)>",
        "activities": [
            {
                "<Activity 1 definition>"
            },
            {
                "<Activity 2 definition>"
            },
            {
                "<Activity N definition>"
            }
        ]
    },
    "name": "MyUntilActivity"
}

형식 속성

속성 설명 허용된 값 필수
name Until 작업의 이름입니다. 문자열
type Until로 설정해야 합니다. 문자열
true 또는 false로 평가되어야 하는 식입니다.
시간 제한 지정한 시간이 지나면 do-until 반복 작업이 시간 초과됩니다. 문자열입니다. d.hh:mm:ss 또는 hh:mm:ss입니다. 기본값은 7일입니다. 최대값은 90일입니다. 아니요
활동 식이 true로 평가될 때까지 실행되는 작업 집합입니다. 작업의 배열

예 1

참고 항목

이 섹션에서는 파이프라인을 실행하는 JSON 정의 및 샘플 PowerShell 명령을 제공합니다. Azure PowerShell 및 JSON 정의를 사용하여 파이프라인을 만드는 단계별 지침이 포함된 연습은 자습서: Azure PowerShell을 사용하여 데이터 팩터리 만들기를 참조하세요.

Until 작업이 포함된 파이프라인

이 예제의 파이프라인에는 UntilWait라는 두 개의 작업이 있습니다. Wait 작업은 반복의 웹 작업을 실행하기 전에 지정한 시간 동안 기다립니다. 식 및 함수에 대한 자세한 내용은 식 언어 및 함수를 참조하세요.

{
    "name": "DoUntilPipeline",
    "properties": {
        "activities": [
            {
                "type": "Until",
                "typeProperties": {
                    "expression": {
                        "value": "@equals('Failed', coalesce(body('MyUnauthenticatedActivity')?.status, actions('MyUnauthenticatedActivity')?.status, 'null'))",
                        "type": "Expression"
                    },
                    "timeout": "00:10:00",
                    "activities": [
                        {
                            "name": "MyUnauthenticatedActivity",
                            "type": "WebActivity",
                            "typeProperties": {
                                "method": "get",
                                "url": "https://www.fake.com/",
                                "headers": {
                                    "Content-Type": "application/json"
                                }
                            },
                            "dependsOn": [
                                {
                                    "activity": "MyWaitActivity",
                                    "dependencyConditions": [ "Succeeded" ]
                                }
                            ]
                        },
                        {
                            "type": "Wait",
                            "typeProperties": {
                                "waitTimeInSeconds": 1
                            },
                            "name": "MyWaitActivity"
                        }
                    ]
                },
                "name": "MyUntilActivity"
            }
        ]
    }
}

예제 2

이 샘플의 파이프라인에서는 입력 폴더의 데이터를 반복의 출력 폴더로 복사합니다. repeat 매개 변수의 값이 false로 설정되거나 1분 후에 시간이 초과되면 반복이 종료됩니다.

Until 작업이 포함된 파이프라인(Adfv2QuickStartPipeline.json)

{
    "name": "Adfv2QuickStartPipeline",
    "properties": {
        "activities": [
            {
                "type": "Until",
                "typeProperties": {
                    "expression":  {
                        "value":  "@equals('false', pipeline().parameters.repeat)", 
                        "type": "Expression"
                    },
                    "timeout": "00:10:00",
                    "activities": [
                        {
                            "name": "CopyFromBlobToBlob",
                            "type": "Copy",
                            "inputs": [
                                {
                                    "referenceName": "BlobDataset",
                                    "parameters": {
                                        "path": "@pipeline().parameters.inputPath"
                                    },
                                    "type": "DatasetReference"
                                }
                            ],
                            "outputs": [
                                {
                                    "referenceName": "BlobDataset",
                                    "parameters": {
                                        "path": "@pipeline().parameters.outputPath"
                                    },
                                    "type": "DatasetReference"
                                }
                            ],
                            "typeProperties": {
                                "source": {
                                    "type": "BlobSource"
                                },
                                "sink": {
                                    "type": "BlobSink"
                                }
                            },
                            "policy": {
                                "retry": 1,
                                "timeout": "00:10:00",
                                "retryIntervalInSeconds": 60
                            }
                        }
                    ]
                },
                "name": "MyUntilActivity"
            }
        ],
        "parameters": {
            "inputPath": {
                "type": "String"
            },
            "outputPath": {
                "type": "String"
            },
            "repeat": {
                "type": "String"
            }                        
        }        
    }
}

Azure Storage 연결 서비스(AzureStorageLinkedService.json)

{
    "name": "AzureStorageLinkedService",
    "properties": {
        "type": "AzureStorage",
        "typeProperties": {
            "connectionString": "DefaultEndpointsProtocol=https;AccountName=<Azure Storage account name>;AccountKey=<Azure Storage account key>"
        }
    }
}

매개 변수화된 Azure Blob 데이터 세트(BlobDataset.json)

파이프라인은 folderPath를 파이프라인의 outputPath1 또는 outputPath2 매개 변수 중 하나의 값으로 설정합니다.

{
    "name": "BlobDataset",
    "properties": {
        "type": "AzureBlob",
        "typeProperties": {
            "folderPath": {
                "value": "@{dataset().path}",
                "type": "Expression"
            }
        },
        "linkedServiceName": {
            "referenceName": "AzureStorageLinkedService",
            "type": "LinkedServiceReference"
        },
        "parameters": {
            "path": {
                "type": "String"
            }
        }
    }
}

파이프라인 매개 변수 JSON(PipelineParameters.json)

{
    "inputPath": "adftutorial/input",
    "outputPath": "adftutorial/outputUntil",
    "repeat": "true"
}

PowerShell 명령

참고 항목

Azure Az PowerShell 모듈을 사용하여 Azure와 상호 작용하는 것이 좋습니다. 시작하려면 Azure PowerShell 설치를 참조하세요. Az PowerShell 모듈로 마이그레이션하는 방법에 대한 자세한 내용은 Azure PowerShell을 AzureRM에서 Azure로 마이그레이션을 참조하세요.

이러한 명령에서는 JSON 파일이 C:\ADF 폴더에 저장되어 있다고 가정합니다.

Connect-AzAccount
Select-AzSubscription "<Your subscription name>"

$resourceGroupName = "<Resource Group Name>"
$dataFactoryName = "<Data Factory Name. Must be globally unique>";
Remove-AzDataFactoryV2 $dataFactoryName -ResourceGroupName $resourceGroupName -force


Set-AzDataFactoryV2 -ResourceGroupName $resourceGroupName -Location "East US" -Name $dataFactoryName
Set-AzDataFactoryV2LinkedService -DataFactoryName $dataFactoryName -ResourceGroupName $resourceGroupName -Name "AzureStorageLinkedService" -DefinitionFile "C:\ADF\AzureStorageLinkedService.json"
Set-AzDataFactoryV2Dataset -DataFactoryName $dataFactoryName -ResourceGroupName $resourceGroupName -Name "BlobDataset" -DefinitionFile "C:\ADF\BlobDataset.json"
Set-AzDataFactoryV2Pipeline -DataFactoryName $dataFactoryName -ResourceGroupName $resourceGroupName -Name "Adfv2QuickStartPipeline" -DefinitionFile "C:\ADF\Adfv2QuickStartPipeline.json"
$runId = Invoke-AzDataFactoryV2Pipeline -DataFactoryName $dataFactoryName -ResourceGroupName $resourceGroupName -PipelineName "Adfv2QuickStartPipeline" -ParameterFile C:\ADF\PipelineParameters.json

while ($True) {
    $run = Get-AzDataFactoryV2PipelineRun -ResourceGroupName $resourceGroupName -DataFactoryName $DataFactoryName -PipelineRunId $runId

    if ($run) {
        if ($run.Status -ne 'InProgress') {
            Write-Host "Pipeline run finished. The status is: " $run.Status -foregroundcolor "Yellow"
            $run
            break
        }
        Write-Host  "Pipeline is running...status: InProgress" -foregroundcolor "Yellow"
        Write-Host "Activity run details:" -foregroundcolor "Yellow"
        $result = Get-AzDataFactoryV2ActivityRun -DataFactoryName $dataFactoryName -ResourceGroupName $resourceGroupName -PipelineRunId $runId -RunStartedAfter (Get-Date).AddMinutes(-30) -RunStartedBefore (Get-Date).AddMinutes(30)
        $result

        Write-Host "Activity 'Output' section:" -foregroundcolor "Yellow"
        $result.Output -join "`r`n"
    }

    Start-Sleep -Seconds 15
}

지원되는 다른 제어 흐름 작업을 참조하세요.