Share via


Configure Logic App 'Until Loop' timeout dynamically.

Question

Wednesday, September 20, 2017 5:30 AM

I would like to pass in a dynamic value to the Logic App's 'Until Loop' timeout. Currently it is set at PT10M. I would like to change it to PT<parameter>M, however it does not work. Is this possible?

Cat

All replies (8)

Tuesday, September 26, 2017 5:50 AM ✅Answered

I'm not sure why it worked on yours Mikael and not mine. I emailed Microsoft and they replied with the text below. It is now working for me, with the 'hack' they described. Thanks for all the help, I really appreciate it.

Microsoft:

It looks like this is due to a bug in the way we evaluate the timeout limit value in the until scope. Using outputs from the triggers or actions when computing the Limit value results in a failure that causes the behavior you are seeing.

There are two ways you can workaround this issue until we have a proper fix:

  1. Remove the triggerBody{} from the limit.timeout property – i.e. make a it a static value
  2. If you really need to make the timeout computation dependent on the payload of the trigger request, you may want to add the “triggerBody()” into the “expression” property of the “until” (this is because we parse the expression when loading dependencies before the action is run. However, we don’t parse the limit property when computing dependencies and that is what is causing this failure.)

For example, you can change your current expression “@equals(20, 10)” to @and(equals(20, 10), equals(triggerBody(), triggerBody()))” – this doesn’t really change the result of the expression, but adds the dependency of triggerBody into the expression.

Hope this helps and will make sure we address the issue in our next deployment.

Cat


Wednesday, September 20, 2017 6:19 AM | 1 vote

Is the parameter a string, or do you convert it into a string?

I tried this real Quick and found that this works (using the expression editor).

concat('PT',variables('MaxNumberToWait'),'H')

The variable MaxNumberToWait is an Integer.

//Mikael Sand - Enfo Sweden

If you find any post helpful, please mark it as such. If I answer your question, humor me with a thank you or mark as answer.


Wednesday, September 20, 2017 6:57 AM

Thanks for the reply. I am not using a variable, I am using a HTTP POST body. I then use the following command, however it doesn't work. Am I missing something?

concat('PT', triggerBody()?['escalationTimeout'],'M')

Cat


Wednesday, September 20, 2017 7:00 AM | 1 vote

I Think its is due to the fact that the escalationTimeout is nullable (btw what is the error message you get?).

Try to do this: Add a variable of type string, and set it to the escalationTimeout value and use the variable in the loop timeout.

//Mikael Sand - Enfo Sweden If you find any post helpful, please mark it as such. If I answer your question, humor me with a thank you or mark as answer.


Wednesday, September 20, 2017 7:43 AM

I have created a variable and added it to the timeout. However it says the error below. I can use the variable in other contexts, but in this one it can't find it. How did you initialize the variable?

InvalidTemplate. Unable to process template language expressions in action 'Until' 'until' limits at line '1' and column '1936': 'Template language expression cannot be evaluated: the template variable 'MaxNumberToWait' cannot be found.'.

Cat


Wednesday, September 20, 2017 7:56 AM

Here is code for a Logic App that gets the timeout value from the post body, initializes a variable and uses it in the timeout. Very bare, but I hope it helps

{
    "definition": {
        "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
        "actions": {
            "Initialize_variable": {
                "inputs": {
                    "variables": [
                        {
                            "name": "TimeoutValue",
                            "type": "String",
                            "value": "@{triggerBody()?['EscalationTimeout']}"
                        }
                    ]
                },
                "runAfter": {},
                "type": "InitializeVariable"
            },
            "Until": {
                "actions": {},
                "expression": "@equals(100, 100)",
                "limit": {
                    "count": 60,
                    "timeout": "@{concat('PT', variables('EscalationTimeout'),'H')}"
                },
                "runAfter": {
                    "Initialize_variable": [
                        "Succeeded"
                    ]
                },
                "type": "Until"
            }
        },
        "contentVersion": "1.0.0.0",
        "outputs": {},
        "parameters": {},
        "triggers": {
            "request": {
                "inputs": {
                    "method": "POST",
                    "schema": {
                        "properties": {
                            "EscalationTimeout": {
                                "type": "number"
                            }
                        },
                        "type": "object"
                    }
                },
                "kind": "Http",
                "type": "Request"
            }
        }
    }
}

//Mikael Sand - Enfo Sweden If you find any post helpful, please mark it as such. If I answer your question, humor me with a thank you or mark as answer.


Wednesday, September 20, 2017 8:53 AM

I tried your example and it worked, however, when you add an action in the loop it doesn't work. Its like your example doesn't wait at all. Do you see this as well?

Cat


Wednesday, September 20, 2017 9:14 AM | 1 vote

Sorry... works on my box. This saves.

Your problem might be somewhere else in the Logic App.

//Mikael Sand - Enfo Sweden If you find any post helpful, please mark it as such. If I answer your question, humor me with a thank you or mark as answer.