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# - 在 C# 中从 IoT Hub 获取数据的简单方法

azure - Azure 中基本层 VM 的 API 是什么?

azure - 如何根据数据库中待处理的项目数量来扩展 Azure 函数应用程序(后台作业)?

azure - 如何从数组变量 [fileName 和 FileContent] 创建 zip 文件。使用azure函数或Azure逻辑应用程序(没有任何第三方服务)

Azure 存储模拟器无法与 azure 函数 docker run 配合使用

.net - 还会有其他.NET 云计算服务提供商吗?

python - Azure 应用服务已启动并正在运行,但显示默认的 Microsoft 页面

azure - 当 Azure Functions 在消耗计划上运行时,如何查看失败的身份验证 (EasyAuthModule_32/64) 日志?

entity-framework - Azure Function 启动中的 EF Core 迁移

c# - 如何从.NET Core API调用Azure门户中的函数App