gpt4 book ai didi

Azure 函数应用程序和 Web 套接字

转载 作者:行者123 更新时间:2023-12-02 05:52:25 25 4
gpt4 key购买 nike

我可以看到函数应用程序中多个地方不支持 Web 套接字。我只想创建一个网络套接字几秒钟,然后再次将其关闭。所以我不需要复杂的套接字框架。我想知道如果不支持此设置,为什么会存在? Microsoft 已开始支持此功能吗?

enter image description here

最佳答案

Azure Functions 通常通过两种方式托管:

  1. 消费计划(无服务器)
  2. 应用服务计划(专用)

消费计划(无服务器)

在此计划中,当服务器空闲时,底层计算机将被取消配置。因此,当计算机空闲并取消配置时,您可能会丢失事件的 Web-Socket 连接。

此外,以下是 Microsoft Azure Function 团队的声明:

There are some challenges here because WebSocket is really a stateful protocol (you have a long lived connection between a given client and a given server) while Azure Functions is designed to be stateless. For example, we will often deprovision a Function App from one VM and start it on a different VM (perhaps in a different scale unit) based on capacity constraints. This is safe to do for us today because of our stateless design - but if we did it when there were WebSockets connections to that VM, we'd be terminating those connections. Source: GitHub

应用服务计划(专用)

如果您使用专用的应用程序服务计划,那么 Web Sockets 肯定会起作用,因为后台有一台机器不是无服务器的(始终可用)。

只需确保您已在配置中启用 Web 套接字(正如您已经完成的那样)。

从此处检查应用服务计划的网络套接字连接限制 - App Service limits Web Sockets Limit

关于Azure 函数应用程序和 Web 套接字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68296480/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com