generated from arcus-azure/arcus.github.template
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: script for resubmitting failed Logic App instances (#385)
Co-authored-by: Pim Simons <[email protected]>
- Loading branch information
1 parent
2baf459
commit 558caa5
Showing
7 changed files
with
401 additions
and
4 deletions.
There are no files selected for viewing
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
Binary file modified
BIN
+76 Bytes
(100%)
src/Arcus.Scripting.LogicApps/Arcus.Scripting.LogicApps.psd1
Binary file not shown.
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
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
50 changes: 50 additions & 0 deletions
50
src/Arcus.Scripting.LogicApps/Scripts/Resubmit-FailedAzLogicAppRuns.ps1
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
param( | ||
[Parameter(Mandatory = $true)][string] $ResourceGroupName = $(throw "Name of the resource group is required"), | ||
[Parameter(Mandatory = $true)][string] $LogicAppName = $(throw "Name of the logic app is required"), | ||
[Parameter(Mandatory = $true)][datetime] $StartTime = $(throw "Start time is required"), | ||
[Parameter(Mandatory = $false)][datetime] $EndTime | ||
) | ||
|
||
try{ | ||
if ($EndTime) { | ||
$runs = Get-AzLogicAppRunHistory -ResourceGroupName $ResourceGroupName -Name $LogicAppName | | ||
Where-Object {$_.Status -eq 'Failed' -and $_.StartTime -ge $StartTime -and $_.EndTime -le $EndTime} | ||
} else { | ||
$runs = Get-AzLogicAppRunHistory -ResourceGroupName $ResourceGroupName -Name $LogicAppName | | ||
Where-Object {$_.Status -eq 'Failed' -and $_.StartTime -ge $StartTime} | ||
} | ||
|
||
$token = Get-AzCachedAccessToken | ||
$accessToken = $token.AccessToken | ||
$subscriptionId = $token.SubscriptionId | ||
|
||
foreach ($run in $runs) { | ||
$triggerName = $run.Trigger.Name | ||
$runId = $run.Name | ||
$resubmitUrl = "https://management.azure.com/subscriptions/$subscriptionId/resourceGroups/$ResourceGroupName/providers/Microsoft.Logic/workflows/$LogicAppName/triggers/$triggerName/histories/$runId/resubmit?api-version=2016-06-01" | ||
|
||
$params = @{ | ||
Method = 'Post' | ||
Headers = @{ | ||
'authorization'="Bearer $accessToken" | ||
} | ||
URI = $resubmitUrl | ||
} | ||
|
||
$web = Invoke-WebRequest @params -ErrorAction Stop | ||
|
||
Write-Verbose "Resubmitted run $runId for the Azure Logic App '$LogicAppName' in resource group '$ResourceGroupName'" | ||
} | ||
|
||
if ($EndTime) { | ||
Write-Host "Successfully resubmitted all failed instances for the Azure Logic App '$LogicAppName' in resource group '$ResourceGroupName' from '$StartTime' and until '$EndTime'" -ForegroundColor Green | ||
} else { | ||
Write-Host "Successfully resubmitted all failed instances for the Azure Logic App '$LogicAppName' in resource group '$ResourceGroupName' from '$StartTime'" -ForegroundColor Green | ||
} | ||
} catch { | ||
if ($EndTime) { | ||
throw "Failed to resubmit all failed instances for the Azure Logic App '$LogicAppName' in resource group '$ResourceGroupName' from '$StartTime' and until '$EndTime'. Details: $($_.Exception.Message)" | ||
} else { | ||
throw "Failed to resubmit all failed instances for the Azure Logic App '$LogicAppName' in resource group '$ResourceGroupName' from '$StartTime'. Details: $($_.Exception.Message)" | ||
} | ||
} |
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
Oops, something went wrong.