Considering this to be my .txt file
In the beginning, I'm just retrieving the text file and converting each line into an array.
Then I have Initialised 2 Variables and set Index to 0 and Status to false
.
In the next step I'm using Until Connector, looping through the Array using outputs('Convert_txt_into_array')[variables('Index')]
and check until the status is set to true.
So, Whether the status becomes true or false the index increments by 1 and loops through the Until connector. If the condition becomes true then the Index Variable is set to the current iteration by using iterationIndexes which gives us the current iteration and exits the Until block.
And Finally, I'm printing Index Variable in Compose connector for future usage [This step can be avoided].
RESULT - 1 :
RESULT - 2 :
Codeview of my logic app
{
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"actions": {
"Compose": {
"inputs": "The @{variables('FindingString')} is at index : @{variables('Index')}",
"runAfter": {
"Until": [
"Succeeded"
]
},
"type": "Compose"
},
"Convert_txt_into_array": {
"inputs": "@split(body('Get_blob_content_(V2)'),'\r\n')",
"runAfter": {
"FindingString": [
"Succeeded"
]
},
"type": "Compose"
},
"FindingString": {
"inputs": {
"variables": [
{
"name": "FindingString",
"type": "string",
"value": "age-34"
}
]
},
"runAfter": {
"Get_blob_content_(V2)": [
"Succeeded"
]
},
"type": "InitializeVariable"
},
"Get_blob_content_(V2)": {
"inputs": {
"host": {
"connection": {
"name": "@parameters('$connections')['azureblob_1']['connectionId']"
}
},
"method": "get",
"path": "/v2/datasets/@{encodeURIComponent(encodeURIComponent('AccountNameFromSettings'))}/files/@{encodeURIComponent(encodeURIComponent('JTJmY29udGFpbmVyJTJmc2FtcGxlVGV4dEZpbGUudHh0'))}/content",
"queries": {
"inferContentType": true
}
},
"metadata": {
"JTJmY29udGFpbmVyJTJmc2FtcGxlVGV4dEZpbGUudHh0": "/container/sampleTextFile.txt"
},
"runAfter": {},
"type": "ApiConnection"
},
"Index": {
"inputs": {
"variables": [
{
"name": "Index",
"type": "integer",
"value": 0
}
]
},
"runAfter": {
"Convert_txt_into_array": [
"Succeeded"
]
},
"type": "InitializeVariable"
},
"Status": {
"inputs": {
"variables": [
{
"name": "Status",
"type": "boolean",
"value": false
}
]
},
"runAfter": {
"Index": [
"Succeeded"
]
},
"type": "InitializeVariable"
},
"Until": {
"actions": {
"Condition": {
"actions": {
"Set_Index": {
"inputs": {
"name": "Index",
"value": "@iterationIndexes('Until')"
},
"runAfter": {
"Set_Status_as_True": [
"Succeeded"
]
},
"type": "SetVariable"
},
"Set_Status_as_True": {
"inputs": {
"name": "Status",
"value": "@true"
},
"runAfter": {},
"type": "SetVariable"
}
},
"else": {
"actions": {
"Set_Status_as_False": {
"inputs": {
"name": "Status",
"value": "@false"
},
"runAfter": {},
"type": "SetVariable"
}
}
},
"expression": {
"and": [
{
"equals": [
"@outputs('Convert_txt_into_array')[variables('Index')]",
"@variables('FindingString')"
]
}
]
},
"runAfter": {},
"type": "If"
},
"Increment_variable": {
"inputs": {
"name": "Index",
"value": 1
},
"runAfter": {
"Condition": [
"Succeeded"
]
},
"type": "IncrementVariable"
}
},
"expression": "@equals(variables('Status'), true)",
"limit": {
"count": 60,
"timeout": "PT1H"
},
"runAfter": {
"Status": [
"Succeeded"
]
},
"type": "Until"
}
},
"contentVersion": "1.0.0.0",
"outputs": {},
"parameters": {
"$connections": {
"defaultValue": {},
"type": "Object"
}
},
"triggers": {
"manual": {
"inputs": {
"schema": {}
},
"kind": "Http",
"type": "Request"
}
}
},
"parameters": {
"$connections": {
"value": {
"azureblob_1": {
"connectionId": "/subscriptions/<Your_Subscription_Id>/resourceGroups/<Your_Resource_Group_Name>/providers/Microsoft.Web/connections/azureblob-1",
"connectionName": "azureblob-1",
"id": "/subscriptions/<Your_Subscription_Id>/providers/Microsoft.Web/locations/northcentralus/managedApis/azureblob"
}
}
}
}
}