0

I am facing the issue with for loop execution with logic APP in azure. Apparently complete playbook execute successfully and functionally its working good. However, i am getting this error because it takes "body" parameter from previous step as input and nothing else. The body is long json and therefore should not be the right input for foreach loop. I tried adding account or Ip address as input but that fails as well.

Input

enter image description here

enter image description here

Output

enter image description here

Please help here

Erik Oppedijk
  • 3,496
  • 4
  • 31
  • 42
Deep
  • 35
  • 1
  • 3
  • 8
  • As far as I know, this error message means there is an action in your "for each" loop failed, but not the "for each" failed. So please provide some more details about your logic app(such as what you want to do in the "for each" action). And please click the "Next failed" to see if there is an action failed in the next loop. – Hury Shen Jan 07 '20 at 09:27
  • And could you please share the screenshot of the two actions' detail in your "for each" loop ? – Hury Shen Jan 07 '20 at 09:37
  • Hi @HuryShen , I have added the screenshot for actions inside for each loop. Also, next iterations of for loop are all failed till 24. only first iteration is green – Deep Jan 07 '20 at 09:56
  • Hi, may I know where is the place of "MachineId" in your json data ? Could you please provide the structure of your json data or an example of your json data ? Thanks. – Hury Shen Jan 07 '20 at 11:08
  • Apart from providing the format or an example of your json data. I saw there are some other actions in your logic app according to the edge of the screenshots which are in parallel with the "For each 2" or before "For each" 2"(I'm not sure). So it should be another "For each 1" ? So in this case, could you please have a try to click the "..." button in the upper right corner of both two "For each" actions and click "settings" and enable "Concurrency Control" and set "Degree of Parallelism" as "1". Please have a try. – Hury Shen Jan 07 '20 at 11:53
  • Hi, any update about this post ? – Hury Shen Jan 08 '20 at 01:01
  • [ { "$id": "4", "DnsDomain": "", "HostName": "#####", "IsDomainJoined": false, "Type": "host", "MachineId": "############################", "MachineIdType": 3 }, { "$id": "5", "Name": "###########", "NTDomain": "###########", "Sid": "####################", "IsDomainJoined": true, "Type": "account" },{.....} ] Above mentioned is the sample JSON structure – Deep Jan 08 '20 at 03:03
  • Hi @HuryShen , I tried with concurrency control setting as well based on an article on the same, However, I am not running any other foreach loop . The parallel logic is just an email sending case. – Deep Jan 08 '20 at 03:04
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/205569/discussion-between-deepanshu-marwah-and-hury-shen). – Deep Jan 08 '20 at 03:11

1 Answers1

0

As you mentioned there is just one item in your json data array which contains "MachineId", I assume the first item contains "MachineId". Please refer to the solution below, it will help you to use the only "MachineId" in the 24 cycles of your loop.

We can input an expression to use the "MachineId" in first item:

body('Parse_JSON')[0].MachineId

enter image description here (In the screenshot above, I just use a "Set variable" to replace your two actions in "For each" loop, but I think there is no difference between them)

Please have a try with this solution~

Hury Shen
  • 14,948
  • 1
  • 9
  • 18
  • The Name dropdown is having blank value Failed to save logic app Test1. The inputs of workflow run action 'Set_variable' of type 'SetVariable' are not valid. The variable 'result' must be initialized before it can be used inside action 'Set_variable' – Deep Jan 08 '20 at 04:32
  • @DEEPANSHUMARWAH No, you don't need to use the "set variable" action as I mentioned. You just need to put the expression into the input box of your "Restrict app execution" action directly. – Hury Shen Jan 08 '20 at 04:35
  • @DEEPANSHUMARWAH As I'm not clear about the two actions you created in your "For each" action, so I used a "Set variable" action instead. – Hury Shen Jan 08 '20 at 04:37
  • Sorry. Mistake. Its running perfect. Thanks for your quick help @Hury Shen – Deep Jan 08 '20 at 04:39