Freigeben über


Azure Cognitive Services with Azure Logic apps - Errors and Workarounds

 

Recently I was working to build a logic app that could analyze tweets using Azure Cognitive services and for each picture in the tweet detect all of the faces.  I ran into an issue because it requires nested for each loops (a tweet could have many pictures, and a picture could have many faces).  Here’s how I was able to work around it while these feature is ready to roll out into production in the next week ( Sept 2017)

Error 1 

When you try to add another foreach to get the output from a Face API output – you will might get the below error (please note this error should be fixed by the first week of September 2017), however in the mean time you can use the below workaround to get past the error.

The error that you will get is - This output is an array. A foreach cannot be nested inside of another foreach.

 

Workaround 

This is because Face API returns an arrary, in order to workaround this error – you can perform the same action by going to the following URL to access your subscription – https://aka.ms/nestedforeach ( this should be fixed in the general release starting next week). You would then be redirected to a newer version which would be something like below:

Once you are in there – you will be able to edit the Azure Logic App and add the required variables without running into the above error.  However you might run into another error when might run into another error which is addressed below

Error 2

 

Update 8/28/2017 - Thanks to the amazing peeps at our Microsoft Product Group -  this issue was fixed just ONE day post reporting to them  :)  PS: the below error may not be relevant anymore.  

Once you are in the newer version by clicking on the link, you will then be able to add the output variables from the Azure Cognitive Services Face API, however once you click to add one of the output variables – you will see that the ability to add more of the output variables is disabled. Please refer screenshot below. This issue too should be fixed by the first week of September 2017. However in order to workaround the error follow the steps mentioned below

  • You will be able to add the first output value, but the minute you add that – the ability to add more output variables from the Azure Cognitive Services Face API is disabled.

Workaround

In order to workaround this – you will need to go to the code. Before going to the code view – fill out place holder values for the fields as text fields – Example : AgeText, GlassesText etc – so that it is easier to replace the placeholder.

Go to the step where you see the variable, in this case – smile, see highlighted

Replace those

  • GenderText --> @{items('For_each_2')?['faceAttributes']?['gender']}
  • Glasses --> @{items('For_each_2')?['faceAttributes']?[glasses]}
  • Smile --> @{items('For_each_2')?['faceAttributes']?[smile]}

And then you will be a happy person [smile ratio – 1.0 :)]

Cheers

Anand Kumar R

Comments

  • Anonymous
    August 31, 2017
    There's definately a great deal to find out about this issue. I like all the points you've made.