Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated script to output csv #477

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions SamplesV2/PastRunDetails/PastRunDetails_ActivityLevelCSV.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
$dataFactoryName = ""
$resourceGroupName = ""
$startTime = "1/12/2023 00:00:00"
$endTime = "1/13/2023 00:00:00"
$filePath = "C:\temp\adfouput.csv"

$pipelineRuns = Get-AzDataFactoryV2PipelineRun -ResourceGroupName $resourceGroupName -DataFactoryName $dataFactoryName -LastUpdatedAfter $startTime -LastUpdatedBefore $endTime

$activityDetails = @()

foreach($pipelineRun in $pipelineRuns) {

$activtiyRuns = Get-AzDataFactoryV2ActivityRun -ResourceGroupName $resourceGroupName -DataFactoryName $dataFactoryName -pipelineRunId $pipelineRun.RunId -RunStartedAfter $startTime -RunStartedBefore $endTime

foreach($activtiyRun in $activtiyRuns) {
if ($null -ne $activtiyRun.Output -and
$null -ne $activtiyRun.Output.SelectToken("billingReference.billableDuration")) {

$billingReference = $activtiyRun.Output.SelectToken("billingReference.billableDuration").ToString() | ConvertFrom-Json
$activityBillingType = $activtiyRun.Output.SelectToken("billingReference.activityType").ToString()

$activityDetails += @{
meterType = $billingReference.meterType
duration = $billingReference.duration
unit = $billingReference.unit
activityBillingType = $activityBillingType
activityType = $activtiyRun.ActivityType.ToString()
activityName = $activtiyRun.ActivityName.ToString()
activityRunStart = $activtiyRun.ActivityRunStart.ToString()
pipelineRunId = $pipelineRun.RunId
pipelineName = $pipelineRun.PipelineName
dataFactoryName = $pipelineRun.DataFactoryName
}
}
}
}

$activityDetails | Export-Csv -Path $filePath
6 changes: 4 additions & 2 deletions SamplesV2/PastRunDetails/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@

## Simple script that prints activity level run details in 45 day range
## PastRunDetails.ps1: Simple script that prints activity level run details in 45 day range

### This is useful for users who want to know which activity ran when for how many hours and corehours. The data can be used:
## PastRunDetails_ActivityLevelCSV.ps1: Script that outputs activity level run details to CSV

### These are useful for users who want to know which activity ran when for how many hours and corehours. The data can be used:

* To understand which activities ran for how long and corehours behind it
* To build future consumption models from past runs
Expand Down