Azure API returns 一般超时错误

Azure API returns generic error for timeout

我需要在api级别设置超时,我用这个

<forward-request timeout="3">

我在微服务中添加了 wait() 来测试这个变化,它按预期工作。

问题出在错误 returned 上,它太笼统了

{
    "statusCode": 500,
    "message": "Internal server error",
    "activityId": "xxxxxxxx"
}

如何让它更具体(超时错误)?

更新 1: 我通过添加这个

找到了解决这个问题的方法
<on-error>
    <set-body>
        @(
            new JObject(
                new JProperty("MsgRsHdr",new JObject(new JProperty("status", "ERROR"))),
                new JProperty("content",new JObject(
                    new JProperty("errors",
                        new JArray(
                            new JObject(
                                new JProperty("code", context.Response.StatusCode.ToString()),
                                new JProperty("message", context.LastError.Message),
                                new JProperty("Reason", context.LastError.Reason),
                                new JProperty("Source", context.LastError.Source),
                                new JProperty("Scope", context.LastError.Scope),
                                new JProperty("Section", context.LastError.Section),
                                new JProperty("Path", context.LastError.Path),
                                new JProperty("PolicyId", context.LastError.PolicyId),
                                new JProperty("type", "Error")
                            )
                        )
                    ),
                    new JProperty("timestamp",DateTime.UtcNow)
                    )
                )
            ).ToString()
        )
    </set-body>
</on-error>

对我来说,这似乎是一种解决方法,而不是 return 更有意义的响应的预期方式。

默认行为背后的想法是,您可以控制要向调用您的 API 的客户公开多少细节。客户并不总是在您的控制之下。使用模板查看 set-body 以使错误响应更易于在策略中阅读。