簡體   English   中英

使用 powershell 從 azure 數據工廠中的管道中刪除觸發器引用

[英]Remove trigger reference from pipeline in azure data factory using powershell

我有一個管道,它在 azure 數據工廠中關聯了觸發器。 我正在嘗試使用 powershell 命令自動化 azure 數據工廠中的一些操作。 在一個用例中,我被阻止了。

用例:用戶更改了關聯觸發器的管道名稱。 (這只是示例,實際上數據工廠中可能存在許多管道/觸發器,用戶可以更改單個或多個管道)

觸發器名稱: TRG_Test1

管道名稱: PL_Test1

因此 TRG_Test1 觸發器附加到管道 PL_Test1。

要求:用戶將名稱從PL_Test1 更改為 PL_Test1_Updated ,關聯的觸發器應從管道中分離(刪除),然后刪除管道並使用新名稱創建新管道並附加(關聯)相同的觸發器。

注意:觸發器詳細信息沒有變化,只有管道詳細信息發生了變化。

通過使用 powershell 的解決方法,我能夠使用 powershell 腳本識別哪個管道與哪個觸發器關聯。 但我無法在移除管道之前分離管道。

錯誤:

無法刪除該文檔,因為它被以下人引用

Set-AzDataFactoryV2Trigger:當觸發器與管道分離並更改以影響管道時,我正在使用此 powershell 命令。

是否有任何 powershell 命令僅刪除管道引用? 任何替代/解決流程以刪除管道的引用?

    ## Detach/Update the trigger
   Set-AzDataFactoryV2Trigger -ResourceGroupName $ADFDeployResourceGroupName -Name $triggerName -DataFactoryName $DataFactoryName -File /$triggerName.json" -Force
                                        
    ##Remove Pipeline
    #Remove-AzDataFactoryV2Pipeline -ResourceGroupName $ADFDeployResourceGroupName -Name $PipelineFileName -DataFactoryName $DataFactoryName -Force

如果要刪除觸發器中的管道引用,請參考以下代碼

Connect-AzAccount


$sub=""
$groupName=""
$factoryName=""
$triggerName=""

Select-AzSubscription -Subscription $sub

$sw=Get-AzResource -ResourceId "/subscriptions/$sub/resourceGroups/$groupName/providers/Microsoft.DataFactory/factories/$factoryName/triggers/$triggerName“ -ExpandProperties


#remove the piplines reference
$pipName="Test" // the pipeline you want to remove
$sw.Properties.pipelines =($sw.Properties.pipelines -ne ($sw.Properties.pipelines|Where-Object{$_.pipelineReference.referenceName -eq $pipName}))

$s=Set-AzResource -ResourceId "/subscriptions/$sub/resourceGroups/$groupName/providers/Microsoft.DataFactory/factories/$factoryName/triggers/$triggerName“   -Properties $sw.Properties -Force 

在此處輸入圖像描述

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM