Description
I've noticed that Function Apps get trigger twice if run from a Logic Apps. This issue is similar to issue #1587.
Repro Steps
Step 1: I created a function app via the Portal
-App name: THFunctionApp
-Location: West Europe
-Consumption Plan
-Runtime Stack: .NET
>In-portal editor
>More templates...
>HTTP trigger
-Name: HttpTrigger1
-Authorization level: Function
>Create
>Save
Step 2: Set the Cors to *
Step 3: Create a Logic Apps
-Name: THLogicApp
-Location: West Europe
> Create
> Edit based on Recurrence template
>+ New step
> Azure Functions
> Select THFunctionApp
> Select HttpTrigger1
-Request Body: {"name":"John"}
-Method: POST
Save
Step 5: Go to the THFunctionApp Function App in the Portal
> Platform feature
> Log streaming
> Wait for the Logic App to fire on the timer
> Observe HttpTrigger1 firing twice for each time the Logic Apps runs
Investigative information
Connecting...
2018-11-28T19:23:12 Welcome, you are now connected to log-streaming service.
2018-11-28T19:24:12 No new trace in the past 1 min(s).
2018-11-28T19:25:12 No new trace in the past 2 min(s).
2018-11-28T19:25:14.525 [Information] Executing 'Functions.HttpTrigger1' (Reason='This function was programmatically called via the host APIs.', Id=7dbd0bb2-662f-4cc2-a0b5-eef961ce03aa)
2018-11-28T19:25:14.526 [Information] C# HTTP trigger function processed a request.
2018-11-28T19:25:14.526 [Information] Executed 'Functions.HttpTrigger1' (Succeeded, Id=7dbd0bb2-662f-4cc2-a0b5-eef961ce03aa)
2018-11-28T19:25:14.525 [Information] Executing 'Functions.HttpTrigger1' (Reason='This function was programmatically called via the host APIs.', Id=7dbd0bb2-662f-4cc2-a0b5-eef961ce03aa)
2018-11-28T19:25:14.526 [Information] C# HTTP trigger function processed a request.
2018-11-28T19:25:14.526 [Information] Executed 'Functions.HttpTrigger1' (Succeeded, Id=7dbd0bb2-662f-4cc2-a0b5-eef961ce03aa)
Please provide the following:
- Timestamp: 2018-11-28T19:25:14.525 (from the Log streaming)
- Function App version (1.0 or 2.0): 2.0.12180.0 (~2)
- Function App name: THFunctionApp
- Function name(s) (as appropriate): HttpTrigger1
- Invocation ID: Where do I find this?
- Region: West Europe
Related information
Function App C#
#r "Newtonsoft.Json"
using System.Net;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Primitives;
using Newtonsoft.Json;
public static async Task Run(HttpRequest req, ILogger log)
{
log.LogInformation("C# HTTP trigger function processed a request.");
string name = req.Query["name"];
string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
dynamic data = JsonConvert.DeserializeObject(requestBody);
name = name ?? data?.name;
return name != null
? (ActionResult)new OkObjectResult($"Hello, {name}")
: new BadRequestObjectResult("Please pass a name on the query string or in the request body");
}
Logic App
{
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"actions": {
"HttpTrigger1": {
"inputs": {
"body": {
"name": "John"
},
"function": {
"id": "/subscriptions/9cafbbe4-e95a-46e5-a35b-d5b0fa305db9/resourceGroups/Examples/providers/Microsoft.Web/sites/THFunctionApp/functions/HttpTrigger1"
},
"method": "POST"
},
"runAfter": {},
"type": "Function"
}
},
"contentVersion": "1.0.0.0",
"outputs": {},
"parameters": {},
"triggers": {
"Recurrence": {
"recurrence": {
"frequency": "Minute",
"interval": 3
},
"type": "Recurrence"
}
}
}
}