通过 Azure Function 处理多个请求

Handle multiple request by Azure Function

请问Azure Function在某一时刻被多次调用,如何处理?

代码示例:

public static class SomeFunction
    {
        [FunctionName(nameof(TestFunction))]
        public static Task<HttpResponseMessage> TestFunction(
            [HttpTrigger(AuthorizationLevel.Function, "GET", Route = "Id/{id}")] HttpRequestMessage req,
            long id)
        {
            return await databaseService.GetById(id);
        }
    }

我的问题:

根据您的应用服务计划,Azure Functions 会自动扩展,因此如果您预计并发调用少于 100 个,则无需担心。 (https://docs.microsoft.com/en-us/azure/azure-functions/functions-scale) 对于数据库连接,这取决于连接池大小和您使用的数据库类型。 通常,您不需要维护静态并发收集,除非您预计请求会突然激增并且出现节流错误。