0
votes

My logic app has an HTTP trigger. Whenever I run the logic app manually or just copy and paste the URL on the browser it works as expected. However, when I use my QueueTriggered azure function to make a call to the logic app URL, the logic app just skips the send email action.

Loggic app design (shows skipped actions)

Action inside ForEach

Here is the code I have for my function app:

public static async Task Run([QueueTrigger("messages", Connection = "ConnectionString")]string myQueueItem, ILogger log)
        {
            var httpClient = HttpClientFactory.Create();
            var url = "logicAppUri";

            await httpClient.GetAsync(url);

        }

The content of the message is just a plain string like "test" for example.

I also tried changing the function app trigger to "When there are messages in the queue" but that also did not work.

"When there are messages in the queue" trigger

Output

I got the same error message from Azure in both cases.

{"code":"ActionConditionFailed","message":"The execution of template action 'Send_email_(V2)' is skipped: there are no items to repeat."}

Which it doesn't make sense since there were messages in the queue.

Any idea why that's happening?

1
I think I need more detail in your flow to know how data going throughTấn Nguyên
Don't use async void use async Task. Consider adding some logging perhaps an error is being thrownpinkfloydx33
I suspect it is some how to do with the messages that you are retrieve from the queues just before the for each loop. Could you please provide more details there? Looks like there are no messages read?Mandar Dharmadhikari
Hi Ygor, please refer to the solution I provided below. If it helps your problem, please accept it as answer(click on the check mark beside my answer to toggle it from greyed out to filled in), thanks in advance~Hury Shen
Thank you for your comments. I've added more information about the problem.Ygor D.

1 Answers

0
votes

According to some test, this issue is caused by using queue triggered function. The queue triggered function will triggered when there are new messages in queue and read the messages. So when the httpClient call the logic app uri in funciton, there are no messages in the queue. The "Get messages" action will get a 0 size list, so the "For each" will execute 0 time.

For your requirement, you can just use "When there are messages in a queue" in logic app. Please refer to my logic app below:

enter image description here

As the trigger will triggered by every message, so we do not need to use "For each" to loop the messages.

Hope it helps~