I have a pipeline which has trigger associated in azure data factory. I am trying to automate some of operations in azure data factory using powershell commands. In one use case, I am blocked.
Use Case: User changed pipeline name which has trigger associated. (This is sample only, in reality many pipelines/triggers may be there in data factory, user may change single or many pipelines)
Trigger Name: TRG_Test1
Pipeline Name: PL_Test1
So TRG_Test1 trigger is attached to pipeline PL_Test1.
Requirement: user changed name from PL_Test1 to PL_Test1_Updated , the associated trigger should be detach(remove) from pipeline and then remove pipeline and create new pipeline with new name and attach(associate) same trigger.
Note: There are no changes in trigger details, only pipelines details changed.
By workaround using powershell, I am able to identify for which pipeline has which trigger associated using powershell script. But I am unable to detach pipeline before removing pipeline.
Error:
The document cannot be deleted since it is referenced by
Set-AzDataFactoryV2Trigger: I am using this powershell command when trigger is detached from pipeline and changes to affect in pipeline.
Is there any powershell command to remove only pipeline references? Any alternative /Work around process to remove references of pipelines?
## 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
If you want to remove the pipeline references in the trigger, please refer to the following code
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.