I'm using azure-cli v 2.8.0 with Python 3.8 on Mac High Sierra. I have a function app that I run locally using
func start
I have my functions defined with the basic folder structure ...
my-func/__init__.py
my-func/function.json
in which the function.json file looks like
{
"scriptFile": "__init__.py",
"bindings": [
{
"authLevel": "anonymous",
"type": "httpTrigger",
"direction": "in",
"name": "req",
"methods": [
"post",
"get"
]
},
{
"type": "http",
"direction": "out",
"name": "$return"
}
]
}
I have a host.json file that looks like
{
"version": "2.0",
"extensionBundle": {
"id": "Microsoft.Azure.Functions.ExtensionBundle",
"version": "[1.*, 2.0.0)"
}
}
Not sure how/where to specify that I want to use the HTTP 2.0 protocol, but it would appear from requests to my local server from an Angular application that I'm using http 1.1, in as far as the inspector tells me

How do I force my local function server to use HTTP 2.0?
It doesn't seem possible: HTTP/2 support is a functionality provided by the Azure Functions networking infrastructure in Azure and it is unavailable locally.
Please, see this issue on the Azure Functions Core Tools Github repository: the developer provides no answer, but they neither say anything contrary to the contributor opinion.
In addition, as you can see in the Azure Functions documentation page, when they talk about the different options supported to start the functions locally, there is no possibility to indicate HTTP/2 support.
If you take a look at the source code of the StartHostAction.cs in the Azure Functions Core Tools Github repository, if you use HTTPS, which is a supported option, it seems that under the hood it will enable Krestrel. But even in that case, in the assumption of the existence of any kind of environment configuration property or something similar to enable that functionality, HTTP/2 is still unsupported in MacOS.
Perhaps, one possibility could be to implement some kind of proxy that supports HTTP/2 between your Angular application and your functions, and route the traffic through it.
For instance, consider the use of the nghttpx HTTP/2 proxy.
For example, you can make nghttpx listen to HTTP/2 requests at port 8443 and if you functions are running on port 7071, run nghttpx from the command line like this (the example is just an adaption of the one provided in the library documentation):
nghttpx -f0.0.0.0,8443 -b127.0.0.1,7071 /path/to/server.key /path/to/server.crt
You can install it with brew or build it from source.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With