通过 flow 来批量cancel running flows

上期介绍了通过powershell来批量cancel running flows。 powershell固然方便,但是很多公司IT 管控不容许AAD 本地CMD/powershell登陆,所以flow是更方便的方式。

我们可以通过UI去cancel, 但是如果量大的情况下肯定不方便(Cancel or resubmit flow runs in bulk in Power Automate - Power Automate | Microsoft Learn

 

 

首先确认账号有premium license

其次创建HTTP with Azure AD

Base Resource URL: https://api.flow.microsoft.com

Azure AD Resource URI (Application ID URI): https://service.flow.microsoft.com

 

Invoke an HTTP request

List Flow Runs: https://api.flow.microsoft.com/providers/Microsoft.ProcessSimple/environments/xxx-flow-env-guidxxx/flows/xxx-flow-guid-xxx/runs?api-version=2016-11-01

Cancel a Flow Run: https://api.flow.microsoft.com/providers/Microsoft.ProcessSimple/environments/{FlowEnvironment}/flo ws/{FlowGUID}/runs/{FlowRunID}/cancel?api-version=2016-11-01

 

因为上面的流只能处理50个flows, 所以要超越这个限制,我们需要做一些额外处理

 

使用do until来继续HTTP request

 

 

 

posted @ 2023-05-10 23:05  TheMiao  阅读(26)  评论(0编辑  收藏  举报