azureazure-functionsazure-function-app-proxy

Azure Functions Proxy - unable to set a HTTP header if value contains JSON


I am trying to set Report-To HTTP header with a proxy function, but the proxy doesn't even start when the value of the header contains a JSON value.

{
    "$schema": "http://json.schemastore.org/proxies",
    "proxies": {
        "proxy1": {
            "debug": true,
            "matchCondition": {
                "methods": [ "GET" ],
                "route": "/{*all}"
            },
            "backendUri": "https://*****.z6.web.core.windows.net/{all}",
            "responseOverrides": {
                "response.headers.Reply-To": "{{ \"TEST\":0 }}"
            }
        }
    }
}

This function returns HTTP error 503 Service unavailable "Functionhost is not running." if I try it on Azure. If started locally, the runtime show the following error message:

[26. 11. 2018 21:29:45] A ScriptHost error has occurred
[26. 11. 2018 21:29:45] Microsoft.Azure.AppService.Proxy.Common: ; expected
[26. 11. 2018 21:29:45] ; expected
[26. 11. 2018 21:29:45] The name 'TEST' does not exist in the current context
[26. 11. 2018 21:29:45] Only assignment, call, increment, decrement, and new object expressions can be used as a statement.
[26. 11. 2018 21:29:45] Stopping Host

Is something wrong with my proxy definition or is it a bug in Azure Functions?


Solution

  • That is valid json, so I feel this is a bug. I've logged an issue here in our repo for this.

    As a workaround, you can change your header value to "{{ 'TEST':0 }}", using single quotes instead of escaped double quotes.