如何使用 PowerShell 创建具有托管虚拟网络的集成运行时

时间:2021-04-07 11:24:05

标签: azure-powershell azure-data-factory-2

我想创建一个带有托管虚拟网络的 Azure 托管集成运行时。 我可以使用 ADF 界面创建它,但我想编写它的脚本。

ADF Portal - Integration runtime setup

这是我正在使用的代码。

Set-AzDataFactoryV2IntegrationRuntime -Name $adfIntegrationRuntimeName `
-ResourceGroupName $adf.ResourceGroupName `
-DataFactoryName $adf.DataFactoryName `
-Type Managed `
-Description $adfIntegrationRuntimeDescription `
-Location $adf.Location `
-DataFlowTimeToLive 10 `
-DataFlowComputeType General `
-DataFlowCoreCount 8

这是使用 UI 的结果:

JSON config - Azure IR with Managed Virtual Network

这是使用 PowerShell 代码的结果:

JSON config - Azure IR subtype Public

您是否知道一种使用 PowerShell 使用子类型“托管虚拟网络”预配 Azure 上托管的 IR 的方法?

enter image description here

1 个答案:

答案 0 :(得分:1)

正如你在 Azure 门户 UI 中看到的,这个配置只是预览,命令 Set-AzDataFactoryV2IntegrationRuntime 中没有内置参数来配置它,如果你想通过 powershell 配置它,你可以调用REST API - Integration Runtimes - Create Or Update 直接在 powershell 中。

示例:

$adfIntegrationRuntimeName = "test1"
$adfIntegrationRuntimeDescription = "123"
$ResourceGroupName = "xxxx"
$ADFname = "joyfactory"
$adf = Get-AzDataFactoryV2 -ResourceGroupName $ResourceGroupName -Name $ADFname
$path = $adf.DataFactoryId + "/integrationruntimes/" + $adfIntegrationRuntimeName + "?api-version=2018-06-01"

$payload = @{
    "name" = $adfIntegrationRuntimeName
    "properties" = @{
        "type" = "Managed"
        "description" = $adfIntegrationRuntimeDescription
        "typeProperties" = @{
            "computeProperties" = @{
                "location" = $adf.Location
                "dataFlowProperties" = @{
                    "computeType" = "General"
                    "coreCount" = 8
                    "timeToLive" =  10
                }
            }
        }
        "managedVirtualNetwork" = @{
            "type" = "ManagedVirtualNetworkReference"
            "referenceName" = "default"
        }
    }
} | ConvertTo-Json -Depth 10

Invoke-AzRestMethod -Path $path -Method PUT -Payload $payload

注意:下面的选项不会映射到Code中,所以如果你想启用它,你还需要在上面的命令之后运行下面的命令。

enter image description here

$path2 = $adf.DataFactoryId + "/integrationruntimes/" + $adfIntegrationRuntimeName + "/enableInteractiveQuery" + "?api-version=2018-06-01"
Invoke-AzRestMethod -Path $path2 -Method POST -Payload '{"autoTerminationMinutes":60}'

enter image description here

检查门户中的结果,它工作正常。

enter image description here