none
Get The Currenty Activity Run ID

    Question

  • How do I get the ActivityRunId of the current activity...

    Activity('activityname').ActivityRunId

    Doesn't work because that references the parent collection e.g. in a loop container for example.

    There seems to be no documentation on the Activity() function.

    Thanks in advance.


    shaun




    Tuesday, October 16, 2018 9:29 AM

All replies

  • How do I get the ActivityRunId of the current activity... Activity('activityname').ActivityRunId

    Doesn't work because that references the parent collection e.g. in a loop container for example.

    There seems to be no documentation on the Activity() function.

    Thanks in advance.


    shaun



    Are you asking about getting the RunID of the Pipeline? Or do you really mean the ID of each activity?  I'm not sure one gets set at the activity level for each run of the pipeline.

    You can access each activity by @activity('activityname') like you have stated, and you can also iterate through it if it's within a foreach or has multiple output records.

    @activity('activityname').output.value or @activity('activityname').output.value[0].

    This stuff isn't well documented, like you have found out, but if you run a pipeline via trigger, you can look in the monitor section and view the pipeline and all of the activity properties available.  Then you can piece together what you can access and use.  Good luck and I hope this helps.

    Tuesday, October 16, 2018 5:01 PM
  • Hello Shaun,

    Have you taken a look at our example of monitoring the Data Factory instance in .NET? 

    // Check the copy activity run details
    Console.WriteLine("Checking copy activity run details...");
    
    List<ActivityRun> activityRuns = client.ActivityRuns.ListByPipelineRun(
    resourceGroup, dataFactoryName, runResponse.RunId, DateTime.UtcNow.AddMinutes(-10), DateTime.UtcNow.AddMinutes(10)).ToList(); 
    if (pipelineRun.Status == "Succeeded")
        Console.WriteLine(activityRuns.First().Output);
    else
        Console.WriteLine(activityRuns.First().Error);
    Console.WriteLine("\nPress any key to exit...");
    Console.ReadKey();

    The above is the example given. The only parameter that should be tough to catch here is runResponse.RunId. You usually retrieve that by requesting a response from the Pipeline:

    CreateRunResponse runResponse = client.Pipelines.CreateRunWithHttpMessagesAsync(resourceGroup, dataFactoryName, pipelineName, parameters: parameters).Result.Body;

    Tuesday, October 16, 2018 5:40 PM