{ "name": "RollbackLoop", "properties": { "activities": [ { "name": "Forward-each", "type": "ForEach", "dependsOn": [], "userProperties": [], "typeProperties": { "items": { "value": "@pipeline().parameters.Input", "type": "Expression" }, "activities": [ { "name": "Attempt Change", "type": "SetVariable", "dependsOn": [], "userProperties": [], "typeProperties": { "variableName": "status", "value": { "value": "@if(contains(item(),'true'),true,item())", "type": "Expression" } } }, { "name": "Track Successes", "type": "AppendVariable", "dependsOn": [ { "activity": "Attempt Change", "dependencyConditions": [ "Succeeded" ] } ], "userProperties": [], "typeProperties": { "variableName": "Finished_values", "value": "@item()" } } ] } }, { "name": "Roll-back each", "type": "ForEach", "dependsOn": [ { "activity": "Forward-each", "dependencyConditions": [ "Failed" ] } ], "userProperties": [], "typeProperties": { "items": { "value": "@variables('Finished_values')", "type": "Expression" }, "activities": [ { "name": "Do Rollback on Item", "type": "SetVariable", "dependsOn": [], "userProperties": [], "typeProperties": { "variableName": "Undoin", "value": "@item()" } } ] } }, { "name": "Only on success", "type": "Wait", "dependsOn": [ { "activity": "Forward-each", "dependencyConditions": [ "Succeeded" ] } ], "userProperties": [], "typeProperties": { "waitTimeInSeconds": 1 } } ], "parameters": { "Input": { "type": "array", "defaultValue": [ "1true", "2true", "3false", "4true" ] } }, "variables": { "Finished_values": { "type": "Array" }, "status": { "type": "Boolean" }, "Undoin": { "type": "String" } }, "annotations": [] } }