Created
January 28, 2018 15:21
-
-
Save bejo73/2fa8d8c30059e0bb95877942a68d0ce0 to your computer and use it in GitHub Desktop.
Search for runs in Logic Apps with PowerShell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param ([Parameter(Mandatory=$true)][string] $ResourceGroup, | |
[Parameter(Mandatory=$true)][string] $Workspace, | |
[Parameter(Mandatory=$true)][string] $Workflow, | |
[Parameter(Mandatory=$true)][string] $Action, | |
[Parameter()][int] $Top = 1000, | |
[Parameter()][int] $To = 0, | |
[Parameter()][int] $From = -31 | |
) | |
$query = "Type=AzureDiagnostics And resource_workflowName_s=$Workflow And resource_actionName_s=$Action And status_s=Succeeded" | |
$date = $(get-date) | |
$end = $date.AddDays($To) | |
$start = $date.AddDays($From) | |
$result = Get-AzureRmOperationalInsightsSearchResults -ResourceGroupName $ResourceGroup -Workspace $Workspace -Query $query -End $end -Start $start -Top $Top | |
$result.Error.Message | |
$searchResults = $result.Value | |
Write-Host "" | |
foreach ($sr in $searchResults) | |
{ | |
$srObj = $sr | ConvertFrom-Json | |
$logicApp = $srObj.resource_workflowName_s | |
$status = $srObj.status_s | |
$runId = $srObj.resource_runId_s | |
$action = $srObj.resource_actionName_s | |
$startTime = $srObj.startTime_t | |
$d = $(Get-Date $startTime).ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss") | |
Write-Host "$d $logicApp $action $status $runId" | |
} | |
Write-Host "" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment