Azure Functions代理-如果值包含JSON,则无法设置HTTP标头

时间:2018-11-28 16:52:40

标签: azure azure-functions azure-function-app-proxy

我正在尝试使用代理功能设置Report-To HTTP标头,但是当标头的值包含JSON值时,代理甚至无法启动。

{
    "$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 }}"
            }
        }
    }
}

此函数返回HTTP错误503服务不可用“ Functionhost未运行”。如果我在Azure上尝试。如果在本地启动,则运行时将显示以下错误消息:

[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

我的代理定义有问题吗?或者它是Azure Functions中的错误?

1 个答案:

答案 0 :(得分:2)

那是有效的json,所以我觉得这是一个错误。为此,我已经在我们的仓库中记录了一个问题here

作为一种解决方法,您可以使用单引号而不是转义的双引号将标头值更改为"{{ 'TEST':0 }}"