azure - Azure Function App 是否同时运行多个实例?

标签 azure azure-function-app

如果我有一个像这样的函数应用

   public static class Function1
    {
        private static readonly HttpClient httpClient = new HttpClient();

        [FunctionName("SomeRandomFunction")]
        public static async Task<IActionResult> Run([HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequest req, ILogger log)
        {
            ulong i = 0;
            Thread.Sleep(10000);
            return (ActionResult)new OkObjectResult($"Hello thread Finished.");
        }
}

是否创建了不同的函数实例,例如移动设备同时触发该功能?

我是从这个quote推断出这一点的“当您使用高级计划时,将根据传入事件的数量添加和删除 Azure Functions 主机的实例,就像使用计划一样”。我参加的是S1计划。

但是,当我像上面那样在函数“SomeRandomFunction”中测试 thread.sleep 时,从两个不同的私有(private)浏览器窗口对同一函数进行两次调用,第二次调用仅在第一个调用完成时才开始。如果可以创建同一函数应用的多个实例,为什么会发生这种情况?

或者多线程实现是否需要同时运行多个实例?

谢谢

最佳答案

Are different instances of the function created if different e.g. mobile devices trigger the function at the same time?

是的。来自文档:

The unit of scale for Azure Functions is the function app. When the function app is scaled out, additional resources are allocated to run multiple instances of the Azure Functions host. Conversely, as compute demand is reduced, the scale controller removes function host instances. The number of instances is eventually scaled in to zero when no functions are running within a function app.

Azure Functions scale and hosting

关于azure - Azure Function App 是否同时运行多个实例?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60764133/

相关文章:

c# - 用户 '<token-identified principal>' 登录失败。使用托管标识使用 Azure Function 应用程序和 Azure SQL 服务时 token 已过期

azure - Azure 中的 Multi-Tenancy 数据架构

Azure 流分析 - 加入 csv 文件返回 0 行

sql - 创建这些表: Could not create constraint or index: Datatype mismatch

azure-functions - 了解 Azure Functions 高级计划计费

java - 使用 Terraform 创建 Azure Function App 时如何设置 java 版本?

azure - 如何在同一资源组中的 Azure Function 应用程序中设置 Key Vault secret ?

部署在 Azure 上的 Node.js。没有安装依赖项

asp.net - 如何在线查看、编辑 Windows Azure 存储中的文档并为其附加签名

azure-functions - Azure 函数无法在 Azure 门户中下载 PowerShell Core 的托管依赖项