@He Gao When trying with a simple API with APIM injecting the trace parent and the backend responding with the trace parent, the final response should already have it.
I assume the backend doesn't include it in the response and/or you build the response object in which case you could still fetch it using context.Request.Headers.GetValueOrDefault("traceparent", "")
policy expression in the outbound
scope.
I tried this out with the Echo API with the following policy document and it worked as expected
<policies>
<inbound>
<base />
</inbound>
<backend>
<base />
</backend>
<outbound>
<base />
<set-header name="X-TRACE-PARENT-ID" exists-action="override">
<value>@(context.Request.Headers.GetValueOrDefault("traceparent", ""))</value>
</set-header>
</outbound>
<on-error>
<base />
</on-error>
</policies>