Azure Api 管理中的单向发送请求有什么问题

What's wrong with this send-one-way-request in Azure Api management

我们在使政策生效时遇到了一些问题。

我们希望在错误大于或等于 400 时记录到外部方 (Loggly)。我们认为这是在出站部分处理的,并且可以通过发送单向请求来实现。我们还尝试通过策略的错误部分进行登录。

代码:

<policies>
    <inbound>
    </inbound>
    <backend>
    </backend>
    <outbound>
            <choose>
                <when condition="@(context.Response.StatusCode >= 400)">
                    <send-one-way-request mode="new">
                        <set-url>http://logs-01.loggly.com/inputs/<uid>/tag/Api_Azure</set-url>
                        <set-method>POST</set-method>
                        <set-body>@{
                            return new JObject(
                                    new JProperty("username","APIM Alert"),
                                    new JProperty("icon_emoji", ":ghost:"),
                                    new JProperty("text", String.Format("{0} {1}\nHost: {2}\n{3} {4}\n User: {5}",
                                                            context.Request.Method,
                                                            context.Request.Url.Path + context.Request.Url.QueryString,
                                                            context.Request.Url.Host,
                                                            context.Response.StatusCode,
                                                            context.Response.StatusReason,
                                                            context.User.Email
                                                            ))
                                    ).ToString();
                        }</set-body>
                    </send-one-way-request>
                </when>
            </choose>
        </outbound>
        <on-error>
            <send-one-way-request mode="new">
                <set-url>http://logs-01.loggly.com/inputs/<uid>/tag/Api_Azure</set-url>
                <set-method>POST</set-method>
                <set-body>TEST outbound ERROR: @(context.LastError.Message)</set-body>
            </send-one-way-request>
        </on-error>
</policies>

此策略的结果是通过单向发送请求发送了一个请求,但在这种情况下使用的 URL 是原始的 URL 而不是中的 URL set-url 标签。

有人知道哪里出了问题吗?

如果您尝试在启用跟踪的情况下执行相同的请求,会发生什么情况? https://azure.microsoft.com/en-us/documentation/articles/api-management-howto-api-inspector/