How to do we trigger a particular ADF Pipeline from Azure Pipelines(Azure DevOps) with parameters/custom conditions to execute ADF pipeline

Madipadiga Ravi Chandra 41 Reputation points
2022-02-26T17:35:47.457+00:00

Hi Everyone,

Is there any possibility to trigger a particular ADF Pipeline from Azure Pipelines , where i will pass some fetch xml queries or custom parameters in azure pipelines as variables which should trigger particular ADF pipeline( I am using copy data activiity in the pipeline to transfer data from source to sink).

Any suggestions/ help will be appreciated.

Thank you.

Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
11,639 questions
0 comments No comments
{count} votes

Accepted answer
  1. Vaibhav Chaudhari 38,921 Reputation points Volunteer Moderator
    2022-02-26T19:48:54.417+00:00

    Add Azure PowerShell task in release pipeline and trigger the ADF pipeline below way:

    Reference:
    https://learn.microsoft.com/en-us/powershell/module/az.datafactory/invoke-azdatafactoryv2pipeline?view=azps-7.2.0
    https://stackoverflow.com/questions/53756570/how-to-pass-arguments-to-adf-pipeline-using-powershell

    Login-AzureRmAccount  
    Select-AzureRmSubscription -Subscription "yourSubId"  
      
    $dfname = "youDataFActoryName"  
    $rgName = "yourResourceGroupName"  
    $pipe = "pipeName"  
    $parameters = @{  
        "param1" = "asdasd"  
        "param2" = "123456"  
    }  
      
    Invoke-AzureRmDataFactoryV2Pipeline -DataFactoryName $dfname -ResourceGroupName $rgName -PipelineName $pipe -Parameter $parameters  
    

    ----------

    Please don't forget to Accept Answer and Up-vote if the response helped -- Vaibhav

    1 person found this answer helpful.
    0 comments No comments

3 additional answers

Sort by: Most helpful
  1. Madipadiga Ravi Chandra 41 Reputation points
    2022-02-27T17:53:07.79+00:00

    Thanks Vaibhav for the solution.

    0 comments No comments

  2. Sergio Tavares Coutinho 1 Reputation point
    2022-11-15T14:26:21.567+00:00

    Hi,

    I have applied the sample script in my Devops pipeline (replacing with my environment informations)

    But when my powershell script runs, it appears to freeze, and after 18 minutes I see this message (critical information are replaced with fake values):


    Starting: Azure PowerShell script: InlineScript

    ******************************************************************************

    Task : Azure PowerShell
    Description : Run a PowerShell script within an Azure environment
    Version : 5.209.0
    Author : Microsoft Corporation

    Help : https://aka.ms/azurepowershelltroubleshooting

    Generating script.
    ========================== Starting Command Output ===========================
    "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command ". 'D:\a_temp\5f69eb3f-c539-4f63-93e6-dacb84b2d2fc.ps1'"
    Added TLS 1.2 in session.
    Import-Module -Name C:\Modules\az_7.5.0\Az.Accounts\2.9.1\Az.Accounts.psd1 -Global
    WARNING: Both Az and AzureRM modules were detected on this machine. Az and AzureRM modules cannot be imported in the
    same session or used in the same script or runbook. If you are running PowerShell in an environment you control you can
    use the 'Uninstall-AzureRm' cmdlet to remove all AzureRm modules from your machine. If you are running in Azure
    Automation, take care that none of your runbooks import both Az and AzureRM modules. More information can be found
    here: https://aka.ms/azps-migration-guide
    Clear-AzContext -Scope CurrentUser -Force -ErrorAction SilentlyContinue
    Clear-AzContext -Scope Process
    Connect-AzAccount -ServicePrincipal -Tenant bx742532-1b53-564d-7708-12y7t668723b -Credential System.Management.Automation.PSCredential -Environment AzureCloud @processScope
    Set-AzContext -SubscriptionId z245g65t-5vtg-1134-ty8q-438058k01234 -TenantId bx742532-1b53-564d-7708-12y7t668723b

    What am i doing wrong?

    Regards

    Sergio

    0 comments No comments

  3. Josh 46 Reputation points
    2023-01-17T19:25:49.1466667+00:00

    i have run the below code but it does not seems to be. i'm geting below rerror

    Invoke-AzDataFactoryV2Pipeline : The term 'Invoke-AzDataFactoryV2Pipeline' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the

    name, or if a path was included, verify that the path is correct and try again.

    Login-AzureRmAccount  
    Select-AzureRmSubscription -Subscription "yourSubId"  
      
    $dfname = "youDataFActoryName"  
    $rgName = "yourResourceGroupName"  
    $pipe = "pipeName"  
    Invoke-AzureRmDataFactoryV2Pipeline -DataFactoryName $dfname -ResourceGroupName $rgName -PipelineName $pipe 
    
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.