在 Azure 数据工厂中创建共享自承载集成运行时Create a shared self-hosted integration runtime in Azure Data Factory

适用于: Azure 数据工厂 Azure Synapse Analytics(预览版)

本指南介绍如何在 Azure 数据工厂中创建共享自承载集成运行时。This guide shows you how to create a shared self-hosted integration runtime in Azure Data Factory. 然后可在另一个数据工厂中使用共享自托管集成运行时。Then you can use the shared self-hosted integration runtime in another data factory.

使用 Azure 数据工厂 UI 创建共享自承载 IRCreate a shared self-hosted IR using Azure Data Factory UI

若要使用 Azure 数据工厂 UI 创建共享自承载 IR,可以执行以下步骤:To create a shared self-hosted IR using Azure Data Factory UI, you can take following steps:

  1. 在要共享的自承载 IR 中,选择“向另一个数据工厂授予权限”,然后在“集成运行时设置”页中,选择要在其中创建链接 IR 的数据工厂。In the self-hosted IR to be shared, select Grant permission to another Data factory and in the "Integration runtime setup" page, select the Data factory in which you want to create the linked IR.

    “共享”选项卡上的授予权限按钮

  2. 记下并复制上面要共享的自承载 IR 的“资源 ID”。Note and copy the above "Resource ID" of the self-hosted IR to be shared.

  3. 在已授予权限的数据工厂中,创建新的自承载 IR(链接),并输入资源 ID。In the data factory to which the permissions were granted, create a new self-hosted IR (linked) and enter the resource ID.

    用于创建自承载集成运行时的按钮

    用于创建链接的自承载集成运行时的按钮

    用于输入名称和资源 ID 的框

使用 Azure PowerShell 创建共享自承载 IRCreate a shared self-hosted IR using Azure PowerShell

若要使用 Azure PowerShell 创建共享自承载 IR,可以执行以下步骤:To create a shared self-hosted IR using Azure PowerShell, you can take following steps:

  1. 创建数据工厂。Create a data factory.
  2. 创建自我托管的集成运行时。Create a self-hosted integration runtime.
  3. 与其他数据工厂共享自承载集成运行时。Share the self-hosted integration runtime with other data factories.
  4. 创建链接的集成运行时。Create a linked integration runtime.
  5. 撤消共享。Revoke the sharing.

先决条件Prerequisites

备注

本文进行了更新,以便使用新的 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 区域列表,请选择你感兴趣的区域:可用产品(按区域)For a list of Azure regions in which Data Factory is currently available, select the regions that interest you on Products available by region.

创建数据工厂Create a data factory

  1. 启动 Windows PowerShell 集成脚本环境 (ISE)。Launch the Windows PowerShell Integrated Scripting Environment (ISE).

  2. 创建变量。Create variables. 复制并粘贴以下脚本。Copy and paste the following script. 将变量(例如 SubscriptionNameResourceGroupName)替换为实际值:Replace the variables, such as SubscriptionName and ResourceGroupName, with actual values:

    # If input contains a PSH special character, e.g. "$", precede it with the escape character "`" like "`$". 
    $SubscriptionName = "[Azure subscription name]" 
    $ResourceGroupName = "[Azure resource group name]" 
    $DataFactoryLocation = "ChinaEast2" 
    
    # Shared Self-hosted integration runtime information. This is a Data Factory compute resource for running any activities 
    # Data factory name. Must be globally unique 
    $SharedDataFactoryName = "[Shared Data factory name]" 
    $SharedIntegrationRuntimeName = "[Shared Integration Runtime Name]" 
    $SharedIntegrationRuntimeDescription = "[Description for Shared Integration Runtime]"
    
    # Linked integration runtime information. This is a Data Factory compute resource for running any activities
    # Data factory name. Must be globally unique
    $LinkedDataFactoryName = "[Linked Data factory name]"
    $LinkedIntegrationRuntimeName = "[Linked Integration Runtime Name]"
    $LinkedIntegrationRuntimeDescription = "[Description for Linked Integration Runtime]"
    
  3. 登录并选择一个订阅。Sign in and select a subscription. 在脚本中添加以下代码,以登录并选择 Azure 订阅:Add the following code to the script to sign in and select your Azure subscription:

    Connect-AzAccount -Environment AzureChinaCloud
    Select-AzSubscription -SubscriptionName $SubscriptionName
    
  4. 创建资源组和数据工厂。Create a resource group and a data factory.

    备注

    此步骤是可选的。This step is optional. 若已有数据工厂,请跳过此步骤。If you already have a data factory, skip this step.

    使用 New-AzResourceGroup 命令创建 Azure 资源组Create an Azure resource group by using the New-AzResourceGroup command. 资源组是在其中以组的形式部署和管理 Azure 资源的逻辑容器。A resource group is a logical container into which Azure resources are deployed and managed as a group. 以下示例在 ChinaEast2 位置创建名为 myResourceGroup 的资源组:The following example creates a resource group named myResourceGroup in the ChinaEast2 location:

    New-AzResourceGroup -Location $DataFactoryLocation -Name $ResourceGroupName
    

    运行以下命令以创建数据工厂:Run the following command to create a data factory:

    Set-AzDataFactoryV2 -ResourceGroupName $ResourceGroupName `
                             -Location $DataFactoryLocation `
                             -Name $SharedDataFactoryName
    

创建自承载 Integration RuntimeCreate a self-hosted integration runtime

备注

此步骤是可选的。This step is optional. 若已经拥有要与其他数据工厂共享的自承载集成运行时,请跳过此步骤。If you already have the self-hosted integration runtime that you want to share with other data factories, skip this step.

运行以下命令以创建自承载集成运行时:Run the following command to create a self-hosted integration runtime:

$SharedIR = Set-AzDataFactoryV2IntegrationRuntime `
    -ResourceGroupName $ResourceGroupName `
    -DataFactoryName $SharedDataFactoryName `
    -Name $SharedIntegrationRuntimeName `
    -Type SelfHosted `
    -Description $SharedIntegrationRuntimeDescription

获取集成运行时身份验证密钥并注册节点Get the integration runtime authentication key and register a node

运行以下命令以获取自承载集成运行时的身份验证密钥:Run the following command to get the authentication key for the self-hosted integration runtime:

Get-AzDataFactoryV2IntegrationRuntimeKey `
    -ResourceGroupName $ResourceGroupName `
    -DataFactoryName $SharedDataFactoryName `
    -Name $SharedIntegrationRuntimeName

响应包含此自承载集成运行时的身份验证密钥。The response contains the authentication key for this self-hosted integration runtime. 注册集成运行时节点时使用此密钥。You use this key when you register the integration runtime node.

安装并注册自承载集成运行时Install and register the self-hosted integration runtime

  1. Azure 数据工厂集成运行时下载自承载集成运行时安装程序。Download the self-hosted integration runtime installer from Azure Data Factory Integration Runtime.

  2. 运行安装程序以在本地计算机上安装自承载集成。Run the installer to install the self-hosted integration on a local computer.

  3. 使用你在上一步中检索的身份验证密钥注册新的自承载集成。Register the new self-hosted integration with the authentication key that you retrieved in a previous step.

与另一个数据工厂共享自承载集成运行时Share the self-hosted integration runtime with another data factory

创建另一个数据工厂Create another data factory

备注

此步骤是可选的。This step is optional. 若已拥有要共享的数据工厂,请跳过此步骤。If you already have the data factory that you want to share with, skip this step. 但若要向/从其他数据工厂添加或删除角色分配,你必须具有 Microsoft.Authorization/roleAssignments/writeMicrosoft.Authorization/roleAssignments/delete 权限,例如用户访问管理员所有者But in order to add or remove role assignments to other data factory, you must have Microsoft.Authorization/roleAssignments/write and Microsoft.Authorization/roleAssignments/delete permissions, such as User Access Administrator or Owner.

$factory = Set-AzDataFactoryV2 -ResourceGroupName $ResourceGroupName `
    -Location $DataFactoryLocation `
    -Name $LinkedDataFactoryName

授予权限Grant permission

向需要访问你创建和注册的自承载集成运行时的数据工厂授予权限。Grant permission to the data factory that needs to access the self-hosted integration runtime you created and registered.

重要

请勿跳过此步骤!Do not skip this step!

New-AzRoleAssignment `
    -ObjectId $factory.Identity.PrincipalId ` #MSI of the Data Factory with which it needs to be shared
    -RoleDefinitionName 'Contributor' `
    -Scope $SharedIR.Id

创建链接的自承载集成运行时Create a linked self-hosted integration runtime

运行以下命令以创建链接的自承载集成运行时:Run the following command to create a linked self-hosted integration runtime:

Set-AzDataFactoryV2IntegrationRuntime `
    -ResourceGroupName $ResourceGroupName `
    -DataFactoryName $LinkedDataFactoryName `
    -Name $LinkedIntegrationRuntimeName `
    -Type SelfHosted `
    -SharedIntegrationRuntimeResourceId $SharedIR.Id `
    -Description $LinkedIntegrationRuntimeDescription

现可在任何链接服务中使用此链接的集成运行时。Now you can use this linked integration runtime in any linked service. 链接的集成运行时使用共享集成运行时来运行活动。The linked integration runtime uses the shared integration runtime to run activities.

撤消数据工厂中的集成运行时共享Revoke integration runtime sharing from a data factory

若要从共享集成运行时中撤销数据工厂的访问权限,请运行以下命令:To revoke the access of a data factory from the shared integration runtime, run the following command:

Remove-AzRoleAssignment `
    -ObjectId $factory.Identity.PrincipalId `
    -RoleDefinitionName 'Contributor' `
    -Scope $SharedIR.Id

若要删除现有的链接集成运行时,请对共享集成运行时运行以下命令:To remove the existing linked integration runtime, run the following command against the shared integration runtime:

Remove-AzDataFactoryV2IntegrationRuntime `
    -ResourceGroupName $ResourceGroupName `
    -DataFactoryName $SharedDataFactoryName `
    -Name $SharedIntegrationRuntimeName `
    -Links `
    -LinkedDataFactoryName $LinkedDataFactoryName

后续步骤Next steps