I have an Azure Function using .NET C# consumption plan (also tested in dedicated plan), triggered by HTTP trigger, and currently I am very confusing with its behaviors
--UPDATE 3: I just realized that it seems like I only have the problem if I use the run through Azure Portal. It runs perfectly if I call it from a browser. So perhaps it is just Microsoft fault.... If it can run normally when it is called from a browser, I don't care if the Portal dies. So please concentrate on the concurrency behavior.
First thing is: it cannot run for more than 30 seconds. In the below picture, you can see that, I only have a very simple Task.Delay. If I set it to lower than 30 seconds. It runs fine. But if I set it to more than 30 seconds, like what is in the picture, it will returns 503 errors.
--UPDATE: THE FULL CODE
#r "Newtonsoft.Json"
using System.Net;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Primitives;
using Newtonsoft.Json;
public static async Task<IActionResult> Run(HttpRequest req, ILogger log)
{
log.LogInformation("C# HTTP trigger function processed a request.");
var datenow = DateTime.Now.ToString("yyyy/mm/dd hh:mm:ss");
await Task.Delay(32000);
return new OkObjectResult("OK..." + Environment.GetEnvironmentVariable("WEBSITE_INSTANCE_ID") + " Start date time: " + datenow );
}
--UPDATE 2: You can raise the Task.Delay to 40000, so the problem can be reproduced easier. Also, if you want to reproduce, please try it multiple time, as it can success and fail randomly.
The second weird behavior is that the Azure Function seems to process things sequentially, while my expectation is that it should process things concurrently. For example. I call the above function, which has a task.delay of 10 second, 2 times, using 2 separated tab from my browser. I noticed that the second call only ran after the first one start
Are those above things normal. Or did I misconfigured something? What I want is that I want a function can be longer than 30 seconds, the longer the better. Also, I want functions to be concurrently run.
Note: I tried the Diagnosis and solve problem but it didn't give me any idea into this.