Get the list of activity names via API

Nandan Hegde 31,511 Reputation points MVP
2022-09-04T07:36:28.737+00:00

Hello All

Below is the JSON for my pipeline :
{
"name": "pipeline6",
"properties": {
"activities": [
{
"name": "Wait1",
"type": "Wait",
"dependsOn": [],
"userProperties": [],
"typeProperties": {
"waitTimeInSeconds": 1
}
},
{
"name": "Set variable1",
"type": "SetVariable",
"dependsOn": [
{
"activity": "Wait1",
"dependencyConditions": [
"Succeeded"
]
}
],
"userProperties": [],
"typeProperties": {
"variableName": "dummy",
"value": {
"value": "@pipeline().parameters.Test",
"type": "Expression"
}
}
},
{
"name": "ForEach1",
"type": "ForEach",
"dependsOn": [
{
"activity": "Set variable1",
"dependencyConditions": [
"Succeeded"
]
}
],
"userProperties": [],
"typeProperties": {
"items": {
"value": "2",
"type": "Expression"
},
"activities": [
{
"name": "Wait2",
"type": "Wait",
"dependsOn": [],
"userProperties": [],
"typeProperties": {
"waitTimeInSeconds": 1
}
},
{
"name": "Wait3",
"type": "Wait",
"dependsOn": [
{
"activity": "Wait2",
"dependencyConditions": [
"Succeeded"
]
}
],
"userProperties": [],
"typeProperties": {
"waitTimeInSeconds": 1
}
},
{
"name": "If Condition2",
"type": "IfCondition",
"dependsOn": [
{
"activity": "Wait3",
"dependencyConditions": [
"Succeeded"
]
}
],
"userProperties": [],
"typeProperties": {
"expression": {
"value": "@equals(pipeline().parameters.Test,'1')",
"type": "Expression"
},
"ifFalseActivities": [
{
"name": "Wait10",
"type": "Wait",
"dependsOn": [],
"userProperties": [],
"typeProperties": {
"waitTimeInSeconds": 1
}
},
{
"name": "Wait11",
"type": "Wait",
"dependsOn": [
{
"activity": "Wait10",
"dependencyConditions": [
"Succeeded"
]
}
],
"userProperties": [],
"typeProperties": {
"waitTimeInSeconds": 1
}
}
],
"ifTrueActivities": [
{
"name": "Wait8",
"type": "Wait",
"dependsOn": [],
"userProperties": [],
"typeProperties": {
"waitTimeInSeconds": 1
}
},
{
"name": "Wait9",
"type": "Wait",
"dependsOn": [
{
"activity": "Wait8",
"dependencyConditions": [
"Succeeded"
]
}
],
"userProperties": [],
"typeProperties": {
"waitTimeInSeconds": 1
}
}
]
}
}
]
}
},
{
"name": "If Condition1",
"type": "IfCondition",
"dependsOn": [
{
"activity": "ForEach1",
"dependencyConditions": [
"Succeeded"
]
}
],
"userProperties": [],
"typeProperties": {
"expression": {
"value": "@equals(pipeline().parameters.Test,'1')",
"type": "Expression"
},
"ifFalseActivities": [
{
"name": "Wait5",
"type": "Wait",
"dependsOn": [],
"userProperties": [],
"typeProperties": {
"waitTimeInSeconds": 1
}
},
{
"name": "Wait7",
"type": "Wait",
"dependsOn": [
{
"activity": "Wait5",
"dependencyConditions": [
"Succeeded"
]
}
],
"userProperties": [],
"typeProperties": {
"waitTimeInSeconds": 1
}
}
],
"ifTrueActivities": [
{
"name": "Wait4",
"type": "Wait",
"dependsOn": [],
"userProperties": [],
"typeProperties": {
"waitTimeInSeconds": 1
}
},
{
"name": "Wait6",
"type": "Wait",
"dependsOn": [
{
"activity": "Wait4",
"dependencyConditions": [
"Succeeded"
]
}
],
"userProperties": [],
"typeProperties": {
"waitTimeInSeconds": 1
}
}
]
}
},
{
"name": "Switch1",
"type": "Switch",
"dependsOn": [
{
"activity": "If Condition1",
"dependencyConditions": [
"Succeeded"
]
}
],
"userProperties": [],
"typeProperties": {
"on": {
"value": "@pipeline().parameters.Test",
"type": "Expression"
},
"cases": [
{
"value": "Case1",
"activities": [
{
"name": "Wait13",
"type": "Wait",
"dependsOn": [],
"userProperties": [],
"typeProperties": {
"waitTimeInSeconds": 1
}
}
]
}
],
"defaultActivities": [
{
"name": "Wait12",
"type": "Wait",
"dependsOn": [],
"userProperties": [],
"typeProperties": {
"waitTimeInSeconds": 1
}
}
]
}
}
],
"parameters": {
"Test": {
"type": "string",
"defaultValue": "1"
}
},
"variables": {
"dummy": {
"type": "String"
}
},
"annotations": [],
"lastPublishTime": "2022-08-26T14:31:34Z"
},
"type": "Microsoft.DataFactory/factories/pipelines"
}

I want to get the list of all activities within that pipeline .

I tried leveraging the below code but I am unable to parse/get the list of activity names within iteration/conditional activities. How can 1 get those details
@PRADEEPCHEEKATLA-MSFT @KranthiPakala-MSFT

$test=(Get-AzDataFactoryV2Pipeline -ResourceGroupName "<<RGName>>" -DataFactoryName “<<ADFName>>” -Name “Pipeline6” -ErrorAction Stop).Activities  
$TEST.name  

Output:
237558-image.png

Note: we are missing the other activity names from the current output.

similar thread:
https://stackoverflow.com/questions/73525586/scan-a-json-for-particular-value

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

1 answer

Sort by: Most helpful
  1. MartinJaffer-MSFT 26,061 Reputation points
    2022-09-06T18:47:41.747+00:00

    Hello @Nandan Hegde ,
    Thanks for the question and using MS Q&A platform.

    As I understand you want to get the name of each activity in a pipeline. Including "sub-activity" or "child activities" found inside loops or conditions.
    Do note, there is a difference between "in a pipeline" and "in a given pipeline run". Specifically, imagine you trigger a pipeline, then afterwards you go and add another activity to the pipeline difinition, publish, and trigger another run. The two pipeline runs will have different activities because the definition was different when each was run.

    Get-AzDataFactoryV2Pipeline fetches the most recent published pipeline definition.
    Get-AzDataFactoryV2ActivityRun gets the activities for a given pipeline run. Details.

    Note that your ForEach has an "activity" or "activities" property. Your If condition has `ifFalseActivites" and "ifTrueActivites". These contain the "child" activities. In similar fashion we can do:

     $test=(Get-AzDataFactoryV2Pipeline -ResourceGroupName "<<RGName>>" -DataFactoryName “<<ADFName>>” -Name “Pipeline6” -ErrorAction Stop).Activities  
    echo "Base activities"  
    foreach ($item in $test) { echo $item.name }  
    echo Sub-activities  
    $test.activity.name  
    $test.activities.name  
    $test.ifTrueActivities.name  
    $test.ifFalseActivities.name  
    

    Please do let me if you have any queries.

    Thanks
    Martin


    • Please don't forget to click on 130616-image.png or upvote 130671-image.png button whenever the information provided helps you. Original posters help the community find answers faster by identifying the correct answer. Here is how
    • Want a reminder to come back and check responses? Here is how to subscribe to a notification
      • If you are interested in joining the VM program and help shape the future of Q&A: Here is how you can be part of Q&A Volunteer Moderators