快速入门:使用 PowerShell 创建 Azure 数据工厂Quickstart: Create an Azure data factory using PowerShell

适用于:是 Azure 数据工厂否 Azure Synapse Analytics(预览版)APPLIES TO: yesAzure Data Factory noAzure Synapse Analytics (Preview)

此快速入门介绍了如何使用 PowerShell 创建 Azure 数据工厂。This quickstart describes how to use PowerShell to create an Azure data factory. 在此数据工厂中创建的管道会将数据从 Azure Blob 存储中的一个文件夹复制到另一个文件夹。The pipeline you create in this data factory copies data from one folder to another folder in an Azure blob storage. 有关如何使用 Azure 数据工厂转换数据的教程,请参阅教程:使用 Spark 转换数据For a tutorial on how to transform data using Azure Data Factory, see Tutorial: Transform data using Spark.

Note

本文不提供数据工厂服务的详细介绍。This article does not provide a detailed introduction of the Data Factory service. 有关 Azure 数据工厂服务的介绍,请参阅 Azure 数据工厂简介For an introduction to the Azure Data Factory service, see Introduction to Azure Data Factory.

先决条件Prerequisites

Azure 订阅Azure subscription

如果没有 Azure 订阅,可在开始前创建一个 1 元人民币试用帐户If you don't have an Azure subscription, create a 1rmb trial account before you begin.

Azure 角色Azure roles

若要创建数据工厂实例,用于登录到 Azure 的用户帐户必须属于参与者或所有者角色,或者是 Azure 订阅的管理员。 To create Data Factory instances, the user account that you use to sign in to Azure must be a member of the contributor or owner role, or an administrator of the Azure subscription. 若要查看你在订阅中拥有的权限,请转到 Azure 门户,在右上角选择你的用户名,然后选择“...” 图标以显示更多选项,然后选择“我的权限” 。To view the permissions that you have in the subscription, go to the Azure portal, select your username in the upper-right corner, select "..." icon for more options, and then select My permissions. 如果可以访问多个订阅,请选择相应的订阅。If you have access to multiple subscriptions, select the appropriate subscription.

若要为数据工厂创建和管理子资源(包括数据集、链接服务、管道、触发器和集成运行时),以下要求适用:To create and manage child resources for Data Factory - including datasets, linked services, pipelines, triggers, and integration runtimes - the following requirements are applicable:

  • 若要在 Azure 门户中创建和管理子资源,你必须属于资源组级别或更高级别的数据工厂参与者角色。To create and manage child resources in the Azure portal, you must belong to the Data Factory Contributor role at the resource group level or above.
  • 若要使用 PowerShell 或 SDK 创建和管理子资源,资源级别或更高级别的参与者角色已足够。To create and manage child resources with PowerShell or the SDK, the contributor role at the resource level or above is sufficient.

有关如何将用户添加到角色的示例说明,请参阅添加角色一文。For sample instructions about how to add a user to a role, see the Add roles article.

有关详细信息,请参阅以下文章:For more info, see the following articles:

Azure 存储帐户Azure Storage account

在本快速入门中,使用常规用途的 Azure 存储帐户(具体的说就是 Blob 存储)作为源 和目标 数据存储。You use a general-purpose Azure Storage account (specifically Blob storage) as both source and destination data stores in this quickstart. 如果没有常规用途的 Azure 存储帐户,请参阅创建存储帐户创建一个。If you don't have a general-purpose Azure Storage account, see Create a storage account to create one.

获取存储帐户名称Get the storage account name

在本快速入门中,将需要 Azure 存储帐户的名称。You will need the name of your Azure Storage account for this quickstart. 以下过程提供的步骤用于获取存储帐户的名称:The following procedure provides steps to get the name of your storage account:

  1. 在 Web 浏览器中,转到 Azure 门户并使用你的 Azure 用户名和密码登录。In a web browser, go to the Azure portal and sign in using your Azure username and password.
  2. 从 Azure 门户菜单中,选择“所有服务”,然后选择“存储” > “存储帐户” 。From the Azure portal menu, select All services, then select Storage > Storage accounts. 此外,也可以在任何页面中搜索和选择“存储帐户” 。You can also search for and select Storage accounts from any page.
  3. 在“存储帐户”页中,筛选你的存储帐户(如果需要),然后选择它 。In the Storage accounts page, filter for your storage account (if needed), and then select your storage account.

此外,也可以在任何页面中搜索和选择“存储帐户” 。You can also search for and select Storage accounts from any page.

创建 Blob 容器Create a blob container

本部分介绍如何在 Azure Blob 存储中创建名为 adftutorial 的 Blob 容器。In this section, you create a blob container named adftutorial in Azure Blob storage.

  1. 在“存储帐户”页上,选择“概述” > “容器”。 From the storage account page, select Overview > Containers.

  2. 在 <Account name> - “容器”页的工具栏中,选择“容器” 。On the <Account name> - Containers page's toolbar, select Container.

  3. 在“新建容器” 对话框中,输入 adftutorial 作为名称,然后选择“确定” 。In the New container dialog box, enter adftutorial for the name, and then select OK. <Account name> - “容器”页已更新为在容器列表中包含“adftutorial” 。The <Account name> - Containers page is updated to include adftutorial in the list of containers.

    容器列表

为 Blob 容器添加输入文件夹和文件Add an input folder and file for the blob container

在此部分中,在刚创建的容器中创建名为“input”的文件夹,再将示例文件上传到 input 文件夹 。In this section, you create a folder named input in the container you just created, and then upload a sample file to the input folder. 在开始之前,打开文本编辑器(如记事本),并创建包含以下内容的名为“emp.txt”的文件 :Before you begin, open a text editor such as Notepad, and create a file named emp.txt with the following content:

John, Doe
Jane, Doe

将此文件保存在 C:\ADFv2QuickStartPSH 文件夹中 。Save the file in the C:\ADFv2QuickStartPSH folder. (如果此文件夹不存在,则创建它。)然后返回到 Azure 门户并执行以下步骤:(If the folder doesn't already exist, create it.) Then return to the Azure portal and follow these steps:

  1. 在上次离开的 <Account name> - “容器”页中,选择已更新的容器列表中的“adftutorial” 。In the <Account name> - Containers page where you left off, select adftutorial from the updated list of containers.

    1. 如果关闭了窗口或转到其他页,请再次登录到 Azure 门户If you closed the window or went to another page, sign in to the Azure portal again.
    2. 从 Azure 门户菜单中,选择“所有服务”,然后选择“存储” > “存储帐户” 。From the Azure portal menu, select All services, then select Storage > Storage accounts. 此外,也可以在任何页面中搜索和选择“存储帐户” 。You can also search for and select Storage accounts from any page.
    3. 选择存储帐户,然后选择“容器” > “adftutorial” 。Select your storage account, and then select Containers > adftutorial.
  2. 在“adftutorial”容器页面的工具栏上,选择“上传” 。On the adftutorial container page's toolbar, select Upload.

  3. 在“上传 Blob”页中,选择“文件”框,然后浏览到 emp.txt 文件并进行选择 。In the Upload blob page, select the Files box, and then browse to and select the emp.txt file.

  4. 展开“高级”标题 。Expand the Advanced heading. 此页现在显示如下内容:The page now displays as shown:

    选择“高级...”链接

  5. 在“上传到文件夹”框中,输入“输入” 。In the Upload to folder box, enter input.

  6. 选择“上传”按钮 。Select the Upload button. 应该会在列表中看到 emp.txt 文件和上传状态。You should see the emp.txt file and the status of the upload in the list.

  7. 选择“关闭”图标 (X) 以关闭“上传 Blob”页面 。Select the Close icon (an X) to close the Upload blob page.

让“adftutorial”容器页面保持打开状态 。Keep the adftutorial container page open. 在本快速入门结束时可以使用它来验证输出。You use it to verify the output at the end of this quickstart.

Azure PowerShellAzure PowerShell

Note

本文进行了更新,以便使用新的 Azure PowerShell Az 模块。This article has been updated to use the new Azure PowerShell Az module. 你仍然可以使用 AzureRM 模块,至少在 2020 年 12 月之前,它将继续接收 bug 修补程序。You can still use the AzureRM module, which will continue to receive bug fixes until at least December 2020. 若要详细了解新的 Az 模块和 AzureRM 兼容性,请参阅新 Azure Powershell Az 模块简介To learn more about the new Az module and AzureRM compatibility, see Introducing the new Azure PowerShell Az module. 有关 Az 模块安装说明,请参阅安装 Azure PowerShellFor Az module installation instructions, see Install Azure PowerShell.

如何安装和配置 Azure PowerShell 中的说明安装最新的 Azure PowerShell 模块。Install the latest Azure PowerShell modules by following instructions in How to install and configure Azure PowerShell.

登录到 PowerShellLog in to PowerShell

  1. 在计算机上启动 PowerShellLaunch PowerShell on your machine. 在完成本快速入门之前,请将 PowerShell 保持打开状态。Keep PowerShell open until the end of this quickstart. 如果将它关闭再重新打开,则需要再次运行这些命令。If you close and reopen, you need to run these commands again.

  2. 运行以下命令,并输入用于登录 Azure 门户的同一 Azure 用户名和密码:Run the following command, and enter the same Azure user name and password that you use to sign in to the Azure portal:

    Connect-AzAccount -Environment AzureChinaCloud
    
  3. 运行以下命令查看此帐户的所有订阅:Run the following command to view all the subscriptions for this account:

    Get-AzSubscription
    
  4. 如果看到多个订阅与帐户相关联,请运行以下命令,选择要使用的订阅。If you see multiple subscriptions associated with your account, run the following command to select the subscription that you want to work with. 请将 SubscriptionId 替换为自己的 Azure 订阅的 ID:Replace SubscriptionId with the ID of your Azure subscription:

    Select-AzSubscription -SubscriptionId "<SubscriptionId>"
    

创建数据工厂Create a data factory

  1. 为资源组名称定义一个变量,稍后会在 PowerShell 命令中使用该变量。Define a variable for the resource group name that you use in PowerShell commands later. 将以下命令文本复制到 PowerShell,在双引号中指定 Azure 资源组的名称,然后运行命令。Copy the following command text to PowerShell, specify a name for the Azure resource group in double quotes, and then run the command. 例如:"ADFQuickStartRG"For example: "ADFQuickStartRG".

    $resourceGroupName = "ADFQuickStartRG";
    

    如果该资源组已存在,请勿覆盖它。If the resource group already exists, you may not want to overwrite it. $ResourceGroupName 变量分配另一个值,然后再次运行命令Assign a different value to the $ResourceGroupName variable and run the command again

  2. 若要创建 Azure 资源组,请运行以下命令:To create the Azure resource group, run the following command:

    $ResGrp = New-AzResourceGroup $resourceGroupName -location 'China East 2'
    

    如果该资源组已存在,请勿覆盖它。If the resource group already exists, you may not want to overwrite it. $ResourceGroupName 变量分配另一个值,然后再次运行命令。Assign a different value to the $ResourceGroupName variable and run the command again.

  3. 定义一个用于数据工厂名称的变量。Define a variable for the data factory name.

    Important

    更新数据工厂名称,使之全局唯一。Update the data factory name to be globally unique. 例如 ADFTutorialFactorySP1127。For example, ADFTutorialFactorySP1127.

    $dataFactoryName = "ADFQuickStartFactory";
    
  4. 若要创建数据工厂,请运行下面的 Set-AzDataFactoryV2 cmdlet,使用 $ResGrp 变量中的 Location 和 ResourceGroupName 属性:To create the data factory, run the following Set-AzDataFactoryV2 cmdlet, using the Location and ResourceGroupName property from the $ResGrp variable:

    $DataFactory = Set-AzDataFactoryV2 -ResourceGroupName $ResGrp.ResourceGroupName `
        -Location $ResGrp.Location -Name $dataFactoryName
    

请注意以下几点:Note the following points:

  • Azure 数据工厂的名称必须全局唯一。The name of the Azure data factory must be globally unique. 如果收到以下错误,请更改名称并重试。If you receive the following error, change the name and try again.

    The specified Data Factory name 'ADFv2QuickStartDataFactory' is already in use. Data Factory names must be globally unique.
    
  • 若要创建数据工厂实例,用于登录到 Azure 的用户帐户必须属于参与者所有者角色,或者是 Azure 订阅的管理员To create Data Factory instances, the user account you use to log in to Azure must be a member of contributor or owner roles, or an administrator of the Azure subscription.

  • 若要查看目前提供数据工厂的 Azure 区域的列表,请在以下页面上选择感兴趣的区域,然后展开“分析” 以找到“数据工厂” :可用产品(按区域)For a list of Azure regions in which Data Factory is currently available, select the regions that interest you on the following page, and then expand Analytics to locate Data Factory: Products available by region. 数据工厂使用的数据存储(Azure 存储、Azure SQL 数据库,等等)和计算资源(HDInsight 等)可以位于其他区域中。The data stores (Azure Storage, Azure SQL Database, etc.) and computes (HDInsight, etc.) used by data factory can be in other regions.

创建链接服务Create a linked service

在数据工厂中创建链接服务,将数据存储和计算服务链接到数据工厂。Create linked services in a data factory to link your data stores and compute services to the data factory. 在本快速入门中,请创建一个 Azure 存储链接服务,用作源存储和接收器存储。In this quickstart, you create an Azure Storage linked service that is used as both the source and sink stores. 链接服务包含的连接信息可供数据工厂服务用来在运行时连接到它。The linked service has the connection information that the Data Factory service uses at runtime to connect to it.

  1. C:\ADFv2QuickStartPSH 文件夹中,创建包含以下内容的名为 AzureStorageLinkedService.json 的 JSON 文件:(创建 ADFv2QuickStartPSH 文件夹(如果不存在)。)Create a JSON file named AzureStorageLinkedService.json in C:\ADFv2QuickStartPSH folder with the following content: (Create the folder ADFv2QuickStartPSH if it does not already exist.).

    Important

    将 <accountName> 和 <accountKey> 分别替换为 Azure 存储帐户的名称和密钥,然后保存文件。Replace <accountName> and <accountKey> with name and key of your Azure storage account before saving the file.

    {
        "name": "AzureStorageLinkedService",
        "properties": {
            "annotations": [],
            "type": "AzureBlobStorage",
            "typeProperties": {
                "connectionString": "DefaultEndpointsProtocol=https;AccountName=<accountName>;AccountKey=<accountKey>;EndpointSuffix=core.chinacloudapi.cn"
            }
        }
    }
    

    如果使用记事本,请在“另存为”对话框中选择“所有文件”作为“另存为类型”字段的值。 If you are using Notepad, select All files for the Save as type filed in the Save as dialog box. 否则,会为文件添加 .txt 扩展。Otherwise, it may add .txt extension to the file. 例如,AzureStorageLinkedService.json.txtFor example, AzureStorageLinkedService.json.txt. 如果先在文件资源管理器中创建该文件,然后再在记事本中将其打开,则可能看不到 .txt 扩展,因为系统默认设置“隐藏已知文件类型的扩展名”选项。 If you create the file in File Explorer before opening it in Notepad, you may not see the .txt extension since the Hide extensions for known files types option is set by default. 在执行下一步骤之前删除 .txt 扩展名。Remove the .txt extension before proceeding to the next step.

  2. PowerShell 中,切换到 ADFv2QuickStartPSH 文件夹。In PowerShell, switch to the ADFv2QuickStartPSH folder.

    Set-Location 'C:\ADFv2QuickStartPSH'
    
  3. 运行 Set-AzDataFactoryV2LinkedService cmdlet 来创建链接服务:AzureStorageLinkedServiceRun the Set-AzDataFactoryV2LinkedService cmdlet to create the linked service: AzureStorageLinkedService.

    Set-AzDataFactoryV2LinkedService -DataFactoryName $DataFactory.DataFactoryName `
        -ResourceGroupName $ResGrp.ResourceGroupName -Name "AzureStorageLinkedService" `
        -DefinitionFile ".\AzureStorageLinkedService.json"
    

    下面是示例输出:Here is the sample output:

    LinkedServiceName : AzureStorageLinkedService
    ResourceGroupName : <resourceGroupName>
    DataFactoryName   : <dataFactoryName>
    Properties        : Microsoft.Azure.Management.DataFactory.Models.AzureBlobStorageLinkedService
    

创建数据集Create datasets

此过程创建两个数据集:InputDataset 和 OutputDataset 。In this procedure, you create two datasets: InputDataset and OutputDataset. 这两个数据集的类型为 BinaryThese datasets are of type Binary. 它们引用在上一部分创建的 Azure 存储链接服务。They refer to the Azure Storage linked service that you created in the previous section. 输入数据集表示输入文件夹中的源数据。The input dataset represents the source data in the input folder. 在输入数据集定义中,请指定包含源数据的 Blob 容器 (adftutorial)、文件夹 (input) 和文件 (emp.txt)。In the input dataset definition, you specify the blob container (adftutorial), the folder (input), and the file (emp.txt) that contain the source data. 输出数据集表示复制到目标的数据。The output dataset represents the data that's copied to the destination. 在输出数据集定义中,请指定要将数据复制到其中的 Blob 容器 (adftutorial)、文件夹 (output) 和文件。In the output dataset definition, you specify the blob container (adftutorial), the folder (output), and the file to which the data is copied.

  1. C:\ADFv2QuickStartPSH 文件夹中创建一个名为 InputDataset.json 的 JSON 文件,使其包含以下内容:Create a JSON file named InputDataset.json in the C:\ADFv2QuickStartPSH folder, with the following content:

    {
        "name": "InputDataset",
        "properties": {
            "linkedServiceName": {
                "referenceName": "AzureStorageLinkedService",
                "type": "LinkedServiceReference"
            },
            "annotations": [],
            "type": "Binary",
            "typeProperties": {
                "location": {
                    "type": "AzureBlobStorageLocation",
                    "fileName": "emp.txt",
                    "folderPath": "input",
                    "container": "adftutorial"
                }
            }
        }
    }
    
  2. 若要创建数据集 InputDataset,请运行 Set-AzDataFactoryV2Dataset cmdlet。To create the dataset: InputDataset, run the Set-AzDataFactoryV2Dataset cmdlet.

    Set-AzDataFactoryV2Dataset -DataFactoryName $DataFactory.DataFactoryName `
        -ResourceGroupName $ResGrp.ResourceGroupName -Name "InputDataset" `
        -DefinitionFile ".\InputDataset.json"
    

    下面是示例输出:Here is the sample output:

    DatasetName       : InputDataset
    ResourceGroupName : <resourceGroupname>
    DataFactoryName   : <dataFactoryName>
    Structure         :
    Properties        : Microsoft.Azure.Management.DataFactory.Models.BinaryDataset
    
  3. 重复创建输出数据集的步骤。Repeat the steps to create the output dataset. C:\ADFv2QuickStartPSH 文件夹中创建一个名为 OutputDataset.json 的 JSON 文件,使其包含以下内容:Create a JSON file named OutputDataset.json in the C:\ADFv2QuickStartPSH folder, with the following content:

    {
        "name": "OutputDataset",
        "properties": {
            "linkedServiceName": {
                "referenceName": "AzureStorageLinkedService",
                "type": "LinkedServiceReference"
            },
            "annotations": [],
            "type": "Binary",
            "typeProperties": {
                "location": {
                    "type": "AzureBlobStorageLocation",
                    "folderPath": "output",
                    "container": "adftutorial"
                }
            }
        }
    }
    
  4. 运行 Set-AzDataFactoryV2Dataset cmdlet 以创建 OutDatasetRun the Set-AzDataFactoryV2Dataset cmdlet to create the OutDataset.

    Set-AzDataFactoryV2Dataset -DataFactoryName $DataFactory.DataFactoryName `
        -ResourceGroupName $ResGrp.ResourceGroupName -Name "OutputDataset" `
        -DefinitionFile ".\OutputDataset.json"
    

    下面是示例输出:Here is the sample output:

    DatasetName       : OutputDataset
    ResourceGroupName : <resourceGroupname>
    DataFactoryName   : <dataFactoryName>
    Structure         :
    Properties        : Microsoft.Azure.Management.DataFactory.Models.BinaryDataset
    

创建管道Create a pipeline

此过程创建一个管道,其中包含的复制活动可使用输入和输出数据集。In this procedure, you create a pipeline with a copy activity that uses the input and output datasets. 复制活动将数据从输入数据集设置中指定的文件复制到输出数据集设置中指定的文件。The copy activity copies data from the file you specified in the input dataset settings to the file you specified in the output dataset settings.

  1. C:\ADFv2QuickStartPSH 文件夹中创建一个名为 Adfv2QuickStartPipeline.json 的 JSON 文件,使其包含以下内容:Create a JSON file named Adfv2QuickStartPipeline.json in the C:\ADFv2QuickStartPSH folder with the following content:

    {
        "name": "Adfv2QuickStartPipeline",
        "properties": {
            "activities": [
                {
                    "name": "CopyFromBlobToBlob",
                    "type": "Copy",
                    "dependsOn": [],
                    "policy": {
                        "timeout": "7.00:00:00",
                        "retry": 0,
                        "retryIntervalInSeconds": 30,
                        "secureOutput": false,
                        "secureInput": false
                    },
                    "userProperties": [],
                    "typeProperties": {
                        "source": {
                            "type": "BinarySource",
                            "storeSettings": {
                                "type": "AzureBlobStorageReadSettings",
                                "recursive": true
                            }
                        },
                        "sink": {
                            "type": "BinarySink",
                            "storeSettings": {
                                "type": "AzureBlobStorageWriteSettings"
                            }
                        },
                        "enableStaging": false
                    },
                    "inputs": [
                        {
                            "referenceName": "InputDataset",
                            "type": "DatasetReference"
                        }
                    ],
                    "outputs": [
                        {
                            "referenceName": "OutputDataset",
                            "type": "DatasetReference"
                        }
                    ]
                }
            ],
            "annotations": []
        }
    }
    
  2. 若要创建管道 Adfv2QuickStartPipeline,请运行 Set-AzDataFactoryV2Pipeline cmdlet。To create the pipeline: Adfv2QuickStartPipeline, Run the Set-AzDataFactoryV2Pipeline cmdlet.

    $DFPipeLine = Set-AzDataFactoryV2Pipeline `
        -DataFactoryName $DataFactory.DataFactoryName `
        -ResourceGroupName $ResGrp.ResourceGroupName `
        -Name "Adfv2QuickStartPipeline" `
        -DefinitionFile ".\Adfv2QuickStartPipeline.json"
    

创建管道运行Create a pipeline run

在此步骤中,将创建管道运行。In this step, you create a pipeline run.

运行 Invoke-AzDataFactoryV2Pipeline cmdlet 以创建一个管道运行。Run the Invoke-AzDataFactoryV2Pipeline cmdlet to create a pipeline run. 此 cmdlet 返回管道运行 ID,用于将来的监视。The cmdlet returns the pipeline run ID for future monitoring.

$RunId = Invoke-AzDataFactoryV2Pipeline `
    -DataFactoryName $DataFactory.DataFactoryName `
    -ResourceGroupName $ResGrp.ResourceGroupName `
    -PipelineName $DFPipeLine.Name 

监视管道运行Monitor the pipeline run

  1. 运行以下 PowerShell 脚本,持续检查管道运行状态,直到完成数据复制为止。Run the following PowerShell script to continuously check the pipeline run status until it finishes copying the data. 在 PowerShell 窗口中复制/粘贴以下脚本,然后按 ENTER。Copy/paste the following script in the PowerShell window, and press ENTER.

    while ($True) {
        $Run = Get-AzDataFactoryV2PipelineRun `
            -ResourceGroupName $ResGrp.ResourceGroupName `
            -DataFactoryName $DataFactory.DataFactoryName `
            -PipelineRunId $RunId
    
        if ($Run) {
            if ($run.Status -ne 'InProgress') {
                Write-Output ("Pipeline run finished. The status is: " +  $Run.Status)
                $Run
                break
            }
            Write-Output "Pipeline is running...status: InProgress"
        }
    
        Start-Sleep -Seconds 10
    }
    

    下面是管道运行的示例输出:Here is the sample output of pipeline run:

    Pipeline is running...status: InProgress
    Pipeline run finished. The status is:  Succeeded
    
    ResourceGroupName : ADFQuickStartRG
    DataFactoryName   : ADFQuickStartFactory
    RunId             : 00000000-0000-0000-0000-0000000000000
    PipelineName      : Adfv2QuickStartPipeline
    LastUpdated       : 8/27/2019 7:23:07 AM
    Parameters        : {}
    RunStart          : 8/27/2019 7:22:56 AM
    RunEnd            : 8/27/2019 7:23:07 AM
    DurationInMs      : 11324
    Status            : Succeeded
    Message           : 
    
  2. 运行以下脚本来检索复制活动运行详细信息,例如,读取/写入的数据的大小。Run the following script to retrieve copy activity run details, for example, size of the data read/written.

    Write-Output "Activity run details:"
    $Result = Get-AzDataFactoryV2ActivityRun -DataFactoryName $DataFactory.DataFactoryName -ResourceGroupName $ResGrp.ResourceGroupName -PipelineRunId $RunId -RunStartedAfter (Get-Date).AddMinutes(-30) -RunStartedBefore (Get-Date).AddMinutes(30)
    $Result
    
    Write-Output "Activity 'Output' section:"
    $Result.Output -join "`r`n"
    
    Write-Output "Activity 'Error' section:"
    $Result.Error -join "`r`n"
    
  3. 确认你看到了与活动运行结果的以下示例输出类似的输出:Confirm that you see the output similar to the following sample output of activity run result:

    ResourceGroupName : ADFQuickStartRG
    DataFactoryName   : ADFQuickStartFactory
    ActivityRunId     : 00000000-0000-0000-0000-000000000000
    ActivityName      : CopyFromBlobToBlob
    PipelineRunId     : 00000000-0000-0000-0000-000000000000
    PipelineName      : Adfv2QuickStartPipeline
    Input             : {source, sink, enableStaging}
    Output            : {dataRead, dataWritten, filesRead, filesWritten...}
    LinkedServiceName :
    ActivityRunStart  : 8/27/2019 7:22:58 AM
    ActivityRunEnd    : 8/27/2019 7:23:05 AM
    DurationInMs      : 6828
    Status            : Succeeded
    Error             : {errorCode, message, failureType, target}
    
    Activity 'Output' section:
    "dataRead": 20
    "dataWritten": 20
    "filesRead": 1
    "filesWritten": 1
    "sourcePeakConnections": 1
    "sinkPeakConnections": 1
    "copyDuration": 4
    "throughput": 0.01
    "errors": []
    "effectiveIntegrationRuntime": "DefaultIntegrationRuntime (China East 2)"
    "usedDataIntegrationUnits": 4
    "usedParallelCopies": 1
    "executionDetails": [
      {
        "source": {
          "type": "AzureBlobStorage"
        },
        "sink": {
          "type": "AzureBlobStorage"
        },
        "status": "Succeeded",
        "start": "2019-08-27T07:22:59.1045645Z",
        "duration": 4,
        "usedDataIntegrationUnits": 4,
        "usedParallelCopies": 1,
        "detailedDurations": {
          "queuingDuration": 3,
          "transferDuration": 1
        }
      }
    ]
    
    Activity 'Error' section:
    "errorCode": ""
    "message": ""
    "failureType": ""
    "target": "CopyFromBlobToBlob"
    

验证输出Verify the output

该管道自动在 adftutorial Blob 容器中创建 output 文件夹,The pipeline automatically creates the output folder in the adftutorial blob container. 然后将 emp.txt 文件从 input 文件夹复制到 output 文件夹。Then, it copies the emp.txt file from the input folder to the output folder.

  1. 在 Azure 门户的“adftutorial”容器页中单击“刷新”,查看输出文件夹。 In the Azure portal, on the adftutorial container page, click Refresh to see the output folder.

    刷新

  2. 单击文件夹列表中的“output”。 Click output in the folder list.

  3. 确认 emp.txt 已复制到 output 文件夹。Confirm that the emp.txt is copied to the output folder.

    刷新

清理资源Clean up resources

可以通过两种方式清理在快速入门中创建的资源。You can clean up the resources that you created in the Quickstart in two ways. 可以删除 Azure 资源组,其中包括资源组中的所有资源。You can delete the Azure resource group, which includes all the resources in the resource group. 若要使其他资源保持原封不动,请仅删除在此教程中创建的数据工厂。If you want to keep the other resources intact, delete only the data factory you created in this tutorial.

删除资源组时会删除所有资源,包括其中的数据工厂。Deleting a resource group deletes all resources including data factories in it. 运行以下命令可以删除整个资源组:Run the following command to delete the entire resource group:

Remove-AzResourceGroup -ResourceGroupName $resourcegroupname

请注意:删除资源组可能需要一些时间。Note: dropping a resource group may take some time. 请耐心等待此过程完成Please be patient with the process

如果只需删除数据工厂,不需删除整个资源组,请运行以下命令:If you want to delete just the data factory, not the entire resource group, run the following command:

Remove-AzDataFactoryV2 -Name $dataFactoryName -ResourceGroupName $resourceGroupName

后续步骤Next steps

此示例中的管道将数据从 Azure Blob 存储中的一个位置复制到另一个位置。The pipeline in this sample copies data from one location to another location in an Azure blob storage. 完成相关教程来了解如何在更多方案中使用数据工厂。Go through the tutorials to learn about using Data Factory in more scenarios.