gpt4 book ai didi

python-3.x - 如何强制本地 Azure 函数服务器使用 HTTP 2.0 而不是 1.1?

转载 作者:行者123 更新时间:2023-12-04 08:35:17 25 4
gpt4 key购买 nike

我在 Mac High Sierra 上使用 azure-cli v 2.8.0 和 Python 3.8。我有一个在本地运行的函数应用程序

func start

我用基本文件夹结构定义了我的函数......

my-func/__init__.py
my-func/function.json

其中 function.json 文件如下所示

{
"scriptFile": "__init__.py",
"bindings": [
{
"authLevel": "anonymous",
"type": "httpTrigger",
"direction": "in",
"name": "req",
"methods": [
"post",
"get"
]
},
{
"type": "http",
"direction": "out",
"name": "$return"
}
]
}

我有一个看起来像这样的 host.json 文件

{
"version": "2.0",
"extensionBundle": {
"id": "Microsoft.Azure.Functions.ExtensionBundle",
"version": "[1.*, 2.0.0)"
}
}

不确定如何/在哪里指定我想要使用 HTTP 2.0 协议(protocol),但据检查员告诉我,它会出现在我正在使用 http 1.1 的 Angular 应用程序向本地服务器发出的请求中

enter image description here

如何强制我的本地功能服务器使用 HTTP 2.0?

最佳答案

这似乎不可能:HTTP/2 支持是 Azure 中的 Azure Functions 网络基础结构提供的功能,并且在本地不可用。

请参阅this issue在 Azure Functions Core Tools Github 存储库上:开发人员没有提供答案,但他们也没有说出任何与贡献者意见相反的内容。

此外,正如您在 Azure Functions documentation page 中看到的那样,当他们谈论支持本地启动功能的不同选项时,不可能指出 HTTP/2 支持。

如果你看一下source code Azure Functions Core Tools Github repository 中的 StartHostAction.cs ,如果您使用 HTTPS(这是受支持的选项),似乎会在幕后启用 Krestrel。但即使在这种情况下,假设存在任何类型的环境配置属性或类似的东西来启用该功能,HTTP/2 is still unsupported在 MacOS 中。

也许,一种可能是在 Angular 应用程序和函数之间实现某种支持 HTTP/2 的代理,并通过它路由流量。

例如,考虑使用 nghttpx HTTP/2 proxy .

例如,您可以让 nghttpx 在端口 8443 监听 HTTP/2 请求,如果您的函数在端口 7071 上运行,像这样从命令行运行 nghttpx(该示例只是库文档中提供的示例的改编):

nghttpx -f0.0.0.0,8443 -b127.0.0.1,7071 /path/to/server.key /path/to/server.crt

您可以使用 brew 安装它或build it from source .

关于python-3.x - 如何强制本地 Azure 函数服务器使用 HTTP 2.0 而不是 1.1?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64828408/

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