Azure APIM と Application Insight で要求を関連付けたいと考えています。API については、インバウンドおよびアウトバウンド セクションで send-request を使用するポリシーがあります。W3C 分散トレース Azure仕様を使用しています
クライアントが traceparent ヘッダーを送信しない場合、インバウンドの send-request はアプリケーション インサイトで関連付けられません。
インバウンド ポリシーで traceparent ヘッダーを設定しようとすると、ポリシーのバックエンド部分で上書きされます。APIM は着信要求をチェックし、traceparent が設定されていない場合はそれを生成するようです。ただし、ポリシーで着信要求にヘッダーを追加することはできません (読み取り専用)。
サンプル ポリシー
<policies>
<inbound>
<base />
<send-request mode="new" response-variable-name="inboundresponse" timeout="10" ignore-error="true">
<set-url>https://someUrl.com</set-url>
<set-method>GET</set-method>
<set-header name="traceparent" exists-action="skip">
<value>00-0af7651916cd43dd8448eb211c80319c-b7ad6b7169203331-01</value>
</set-header>
<set-body></set-body>
</send-request>
<!-- for test set fixed value, but this value is overwritten by Azure APIM in backend
and all 3 requests are not coorrelated -->
<set-header name="traceparent" exists-action="skip">
<value>00-0af7651916cd43dd8448eb211c80319c-b7ad6b7169203331-01</value>
</set-header>
</inbound>
<backend>
<base />
</backend>
<outbound>
<base />
<!-- traceparent value we get here is not the same that we set -->
<send-request mode="new" response-variable-name="outboundresponse" timeout="10" ignore-error="true">
<set-url>https://someUrl.com</set-url>
<set-method>GET</set-method>
<set-header name="traceparent" exists-action="skip">
<value>00-0af7651916cd43dd8448eb211c80319c-b7ad6b7169203331-01</value>
</set-header>
<set-body></set-body>
</send-request>
</outbound>
<on-error>
<base />
</on-error>
</policies>