All scripts
Azure AI 427
Get-AzureLogicAppRunHistoryReport
Pulls recent run history for every Logic App in a resource group or subscription, exports it to CSV, and summarizes failed runs per app so you know where to look first.
Get-AzureLogicAppRunHistoryReport.ps1
<#
.SYNOPSIS
Reports recent run history for Azure Logic Apps, highlighting failed runs.
.DESCRIPTION
Connects to Azure using the Az module and pulls run history for every Logic
App in a resource group, or across the whole subscription if no resource
group is given. For each run it records the status, start and end time,
and how long the run took, then prints a summary count of failed runs per
Logic App so you can spot the ones worth investigating first. Useful for a
quick health check without opening every Logic App in the portal one by
one.
.AUTHOR
Shehryar Hassan
.EXAMPLE
.\Get-AzureLogicAppRunHistoryReport.ps1 -ResourceGroupName "rg-integration" -DaysBack 3
Reports on all Logic Apps in the rg-integration resource group for the
last 3 days and exports the results to a CSV in the current folder.
#>
[CmdletBinding()]
param(
[Parameter(Mandatory = $false)]
[string]$ResourceGroupName,
[Parameter(Mandatory = $false)]
[int]$DaysBack = 7,
[Parameter(Mandatory = $false)]
[string]$OutputPath = ".\LogicAppRunHistory.csv"
)
if (-not (Get-AzContext)) {
Write-Host "No active Azure session found, connecting now." -ForegroundColor Yellow
Connect-AzAccount | Out-Null
}
if ($ResourceGroupName) {
$logicApps = Get-AzLogicApp -ResourceGroupName $ResourceGroupName
} else {
$logicApps = Get-AzLogicApp
}
if (-not $logicApps) {
Write-Host "No Logic Apps found in scope." -ForegroundColor Yellow
return
}
$cutoff = (Get-Date).AddDays(-$DaysBack)
$results = @()
foreach ($app in $logicApps) {
Write-Host "Checking run history for $($app.Name)..." -ForegroundColor Cyan
$runs = Get-AzLogicAppRunHistory -ResourceGroupName $app.ResourceGroupName -Name $app.Name |
Where-Object { $_.StartTime -ge $cutoff }
foreach ($run in $runs) {
$duration = $null
if ($run.EndTime -and $run.StartTime) {
$duration = [math]::Round((New-TimeSpan -Start $run.StartTime -End $run.EndTime).TotalSeconds, 1)
}
$results += [PSCustomObject]@{
LogicAppName = $app.Name
ResourceGroup = $app.ResourceGroupName
RunName = $run.Name
Status = $run.Status
StartTime = $run.StartTime
EndTime = $run.EndTime
DurationSec = $duration
}
}
}
if ($results.Count -eq 0) {
Write-Host "No runs found in the last $DaysBack day(s)." -ForegroundColor Yellow
return
}
$results | Export-Csv -Path $OutputPath -NoTypeInformation
Write-Host "Exported $($results.Count) run records to $OutputPath" -ForegroundColor Green
Write-Host "`nFailed run summary by Logic App:" -ForegroundColor Cyan
$results |
Where-Object { $_.Status -eq "Failed" } |
Group-Object LogicAppName |
Sort-Object Count -Descending |
ForEach-Object {
Write-Host (" - {0}: {1} failed run(s)" -f $_.Name, $_.Count) -ForegroundColor Red
}
$totalFailed = ($results | Where-Object { $_.Status -eq "Failed" }).Count
Write-Host "`nTotal runs checked: $($results.Count), failed: $totalFailed" -ForegroundColor Cyan
Read it before you run it, and test in a safe tenant first.