arcus-azure / arcus.scripting

Scripting with Microsoft Azure in a breeze.
https://scripting.arcus-azure.net/
MIT License
9 stars 11 forks source link

Add script to cancel all running Logic Apps #361

Closed scleynen closed 1 year ago

scleynen commented 1 year ago

Is your feature request related to a problem? Please describe. Sometimes fe. when accidently a big load is triggered you want to cancel all running instances of a LogicApp. In the portal you can do it only on individual base.

Describe the solution you'd like This powershell is something I found, but Get-AzureRmLogicAppRunHistory is not giving all results at once. It is "paged". So we need a sript which is following the nextlink in the paged result an cancels all the running.

$runs = Get-AzureRmLogicAppRunHistory -ResourceGroupName "Test" -Name "Canvas" | 
    Where-Object {$_.Status -eq 'Running'} | 
    Stop-AzureRmLogicAppRun -ResourceGroupName "Test" -Name "Canvas" -RunName {$_.Name} -Force
stijnmoreels commented 1 year ago

Thank you @scleynen for your issue!

pim-simons commented 1 year ago

I see there is a new Az version of this script, see https://learn.microsoft.com/en-us/powershell/module/az.logicapp/get-azlogicapprunhistory?view=azps-9.3.0. This Az script has the parameters FollowNextPageLink and MaximumFollowNextPageLink, it would seem that script is able to follow the nextLink pages "out-of-the-box".

@scleynen could you test if the Get-AzLogicAppRunHistory does the job for you?

scleynen commented 1 year ago

Yes that worked.

But nevertheless it would be a handy script to have available without google it all the time.

pim-simons commented 1 year ago

Great to hear it worked! Could you share the entire powershell script you used with Get-AzLogicAppRunHistory to cancel all running Logic Apps? So I can see if and how we can best implement this in Arcus.Scripting.LogicApps.