如果不存在则创建Azure数据工厂集成运行时-Azure PowerShell

时间:2019-04-17 13:01:14

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

我已经在Azure Portal中创建了Azure Data Factory Integration Runtime,现在想通过PowerShell脚本

   $IR = Get-AzDataFactoryV2IntegrationRuntime -DataFactoryName "CappDashboardDataFactory" -ResourceGroupName "ADFResourceGroup" -Name "CappDashboardDataFactory-Selfhosted-IR"
if(-not $IR)
{
Set-AzDataFactoryV2IntegrationRuntime -ResourceGroupName "ADFResourceGroup" -DataFactoryName "CappDashboardDataFactory" -Name "CappDashboardDataFactory-Selfhosted-IR" -Type SelfHosted -Description "selfhosted IR description"
# created successfully
 Write-Output "Created Successfully"
}
else
{
 # already exists
 Write-Output "Already Exists"
}

当我运行脚本时,它不会显示来自else块的消息。谁能帮忙 enter image description here

2 个答案:

答案 0 :(得分:0)

我尝试了相同的代码,对我有用。仍然,如果您想交叉验证,可以通过调用下面的函数来做到这一点。

Get-AzDataFactoryV2IntegrationRuntime -ResourceGroupName rg-test-dfv2 -DataFactoryName test-df-eu2 -Name test-dedicated-ir

It will give you following result which you can verify later

    Location                     : West US
    NodeSize                     : Standard_D1_v2
    NodeCount                    : 1
    MaxParallelExecutionsPerNode : 1
    CatalogServerEndpoint        : test.database.windows.net
    CatalogAdminUserName         : test
    CatalogAdminPassword         : **********
    CatalogPricingTier           : S1
    VNetId                       : 
    Subnet                       : 
    State                        : Starting
    ResourceGroupName            : rg-test-dfv2
    DataFactoryName              : test-df-eu2
    Name                         : test-dedicated-ir
    Description                  : Reserved IR

希望有帮助。

答案 1 :(得分:0)

您必须调整if语句:

if($null -eq $IR)