I had a logic app that started with a queue trigger followed by a ForEach statement. The Logic App run failed on the ForEach step with the following error message:
ExpressionEvaluationFailed. The execution of template action ‘For_each’ failed: the result of the evaluation of ‘foreach’ expression ‘@triggerBody()?[‘QueueMessagesList’]?[‘QueueMessage’]’ is of type ‘Null’. The result must be a valid array.
Stop searching for a solution and go to the settings of the queue trigger by clicking the dots in the Logic App Designer. You will notice that the option Split On is enabled by default. That’s the problem. You can’t use a ForEach on the queue messagelist when the contents of the queue are already split. Disable Split On. Concurrency Control will automatically be switched on. Use the slider to set Degree of Parallelism to 1. You don’t have to set this option to 1, it’s just the safest option (nothing happening in parallel).
Note. When you deploy a logic app, the trigger is no longer run automatically. That’s a recent Azure change you should be aware of. Actually very nice, because there might be cases you don’t want to have the trigger going off automatically to prevent errors from happening.