generated from arcus-azure/arcus.github.template
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Support Logic App Standard (#415)
Co-authored-by: Stijn Moreels <9039753+stijnmoreels@users.noreply.github.com> Co-authored-by: Pim Simons <pim.simons@codit.eu>
- Loading branch information
1 parent
9da6ae5
commit 4624a4e
Showing
31 changed files
with
1,413 additions
and
249 deletions.
There are no files selected for viewing
92 changes: 46 additions & 46 deletions
92
...3-Features/powershell/azure-logic-apps.md → ...owershell/azure-logic-apps-consumption.md
Large diffs are not rendered by default.
Oops, something went wrong.
354 changes: 354 additions & 0 deletions
354
docs/preview/03-Features/powershell/azure-logic-apps-standard.md
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file modified
BIN
+160 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
79 changes: 71 additions & 8 deletions
79
src/Arcus.Scripting.LogicApps/Scripts/Cancel-AzLogicAppRuns.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 |
---|---|---|
@@ -1,19 +1,82 @@ | ||
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 = $false)][string] $WorkflowName = "", | ||
[Parameter(Mandatory = $false)][string] $EnvironmentName = "AzureCloud", | ||
[Parameter(Mandatory = $false)][int] $MaximumFollowNextPageLink = 10 | ||
) | ||
|
||
try { | ||
$runs = Get-AzLogicAppRunHistory -ResourceGroupName $ResourceGroupName -Name $LogicAppName -FollowNextPageLink -MaximumFollowNextPageLink $MaximumFollowNextPageLink | | ||
Where-Object {$_.Status -eq 'Running'} | ||
if ($WorkflowName -eq "") { | ||
$runs = Get-AzLogicAppRunHistory -ResourceGroupName $ResourceGroupName -Name $LogicAppName -FollowNextPageLink -MaximumFollowNextPageLink $MaximumFollowNextPageLink | | ||
Where-Object {$_.Status -eq 'Running'} | ||
|
||
foreach ($run in $runs) { | ||
Stop-AzLogicAppRun -ResourceGroupName $ResourceGroupName -Name $LogicAppName -RunName $run.Name -Force | ||
Write-Verbose "Cancelled run $run.Name for the Azure Logic App '$LogicAppName' in resource group '$ResourceGroupName'" | ||
} | ||
foreach ($run in $runs) { | ||
$runName = $run.name | ||
Stop-AzLogicAppRun -ResourceGroupName $ResourceGroupName -Name $LogicAppName -RunName $runName -Force | ||
Write-Verbose "Cancelled run '$runName' for the Azure Logic App '$LogicAppName' in resource group '$ResourceGroupName'" | ||
} | ||
|
||
Write-Host "Successfully cancelled all running instances for the Azure Logic App '$LogicAppName' in resource group '$ResourceGroupName'" -ForegroundColor Green | ||
} else { | ||
$token = Get-AzCachedAccessToken | ||
$accessToken = $token.AccessToken | ||
$subscriptionId = $token.SubscriptionId | ||
|
||
$listRunningUrl = . $PSScriptRoot\Get-AzLogicAppStandardResourceManagementUrl.ps1 -EnvironmentName $EnvironmentName -SubscriptionId $subscriptionId -ResourceGroupName $ResourceGroupName -LogicAppName $LogicAppName -WorkflowName $WorkflowName -Action 'listRunning' | ||
$listRunningParams = @{ | ||
Method = 'Get' | ||
Headers = @{ | ||
'authorization'="Bearer $accessToken" | ||
} | ||
URI = $listRunningUrl | ||
} | ||
|
||
$runs = Invoke-WebRequest @listRunningParams -ErrorAction Stop | ||
$runsContent = $runs.Content | ConvertFrom-Json | ||
$allRuns = $runsContent.value | ||
|
||
if ($runsContent.nextLink -ne $null) { | ||
$nextPageCounter = 1 | ||
$nextPageUrl = $runsContent.nextLink | ||
while ($nextPageUrl -ne $null -and $nextPageCounter -le $MaximumFollowNextPageLink) { | ||
$nextPageCounter = $nextPageCounter + 1 | ||
$listRunningParams = @{ | ||
Method = 'Get' | ||
Headers = @{ | ||
'authorization'="Bearer $accessToken" | ||
} | ||
URI = $nextPageUrl | ||
} | ||
|
||
Write-Host "Successfully cancelled all running instances for the Azure Logic App '$LogicAppName' in resource group '$ResourceGroupName'" -ForegroundColor Green | ||
$runsNextPage = Invoke-WebRequest @listRunningParams -ErrorAction Stop | ||
$runsNextPageContent = $runsNextPage.Content | ConvertFrom-Json | ||
$nextPageUrl = $runsNextPageContent.nextLink | ||
$allRuns = $allRuns + $runsNextPageContent.value | ||
} | ||
} | ||
|
||
foreach ($run in $allRuns) { | ||
$runName = $run.name | ||
|
||
$cancelUrl = . $PSScriptRoot\Get-AzLogicAppStandardResourceManagementUrl.ps1 -EnvironmentName $EnvironmentName -SubscriptionId $subscriptionId -ResourceGroupName $ResourceGroupName -LogicAppName $LogicAppName -WorkflowName $WorkflowName -RunName $runName -Action 'cancel' | ||
$cancelParams = @{ | ||
Method = 'Post' | ||
Headers = @{ | ||
'authorization'="Bearer $accessToken" | ||
} | ||
URI = $cancelUrl | ||
} | ||
$cancel = Invoke-WebRequest @cancelParams -ErrorAction Stop | ||
Write-Verbose "Cancelled run '$runName' for the workflow '$WorkflowName' in Azure Logic App '$LogicAppName' in resource group '$ResourceGroupName'" | ||
} | ||
|
||
Write-Host "Successfully cancelled all running instances for the workflow '$WorkflowName' in Azure Logic App '$LogicAppName' in resource group '$ResourceGroupName'" -ForegroundColor Green | ||
} | ||
} catch { | ||
throw "Failed to cancel all running instances for the Azure Logic App '$LogicAppName' in resource group '$ResourceGroupName'. Details: $($_.Exception.Message)" | ||
if ($WorkflowName -eq "") { | ||
throw "Failed to cancel all running instances for the Azure Logic App '$LogicAppName' in resource group '$ResourceGroupName'. Details: $($_.Exception.Message)" | ||
} else { | ||
throw "Failed to cancel all running instances for the workflow '$WorkflowName' in Azure Logic App '$LogicAppName' in resource group '$ResourceGroupName'. 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.