'Set-AzDataFactoryV2Trigger fails in Azure Powershell Task in Release pipeline but works fine on Powershell in frontend machine


I want to create all the triggers in ADF after the Release pipeline has been run successfully . This is because there is a hard 256 parameters limit for ARM template max no. of parameters.
The idea is we will delete all the triggers in DEV, TEST, QA and in PROD. In our published artifact, we would have all the JSONs trigger files using which we can create triggers. The Release pipeline would run a PowerShell script and create the Triggers using Set-AzDataFactoryV2Trigger.
I am able to run the below script correctly on my frontend -
$AllTriggers = Get-ChildItem -Path .
Write-Host $AllTriggers
    

$AllTriggers | ForEach-Object { 
Set-AzDataFactoryV2Trigger -ResourceGroupName "<MyResourceGroupName>" -DataFactoryName "<MyTargetDataFactoryName>" -Name "$_" -DefinitionFile ".\$_.json"
}

In the Azure Powershell script, the first line has to be changed a little to read all the JSON's from the Published Artifact -

$AllTriggers = Get-ChildItem -Name -Path "./_TriggerCreations/drop/" -Include *.json

I receive the below error when trying to run this script via Az Powershell task in the release pipeline (you may note that the error is gibberish) -

enter image description here

The yellow blurred line is the name of the Trigger. Stuck on this for some time now. Any help would be highly appreciated.

Regards,
Sree



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source