Last active
October 28, 2022 16:04
-
-
Save andrew-grischenko/a2d42fd707632c0928e72047fb7741fd to your computer and use it in GitHub Desktop.
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
... | |
let responseMessage: string = ''; | |
const statusOptions = [ 'All', 'Running', 'Failed', 'Cancelled', 'Succeeded' ]; | |
const NO_FILTER = 0; | |
var runsList = { | |
runs: [] | |
}; | |
let runsCount = 0; | |
let nextLink: string = `https://management.azure.com/providers/Microsoft.ProcessSimple/scopes/admin/environments/${environment}/flows/${flow}/runs?api-version=2016-11-01`; | |
if(statusOption != statusOptions[NO_FILTER]) | |
nextLink += `&$filter=Status%20eq%20%27${statusOption.toLowerCase()}%27`; | |
try { | |
while(nextLink && runsCount <= RUNS_LIMIT) { | |
await getHttp(nextLink, | |
req.headers['authorization']) | |
.then(runs => { | |
if(!runs || !runs.value) | |
throw Error('No runs found - the response is unexpected'); | |
const items = (periodOption != periodOptions[NO_FILTER]) ? | |
runs.value.filter( (item) => new Date(item.properties.startTime) >= dateFrom && new Date(item.properties.startTime) <= dateTo) : | |
runs.value; | |
items.forEach(element => { | |
runsList.runs.push( | |
{ | |
'id': element.id, | |
'name': element.name, | |
'type': element.type, | |
'properties': element.properties | |
} | |
) | |
}); | |
runsCount += items.length; | |
nextLink = runs.nextLink; | |
}); | |
} | |
responseMessage = JSON.stringify(runsList); | |
context.log(`Total runs found: ${runsList.runs.length}`); | |
} | |
catch ( err ) { | |
responseMessage = `Error: ${err}`; | |
} | |
... |
How could I get the latest single run from the run history?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi Andrew,
what type of scope do you used ?