question

SrinivasuluValleti-9007 avatar image
0 Votes"
SrinivasuluValleti-9007 asked SrinivasuluValleti-9007 commented

Application Gateway Rewrites - Custom Header Value (Autogenerated Unique Correlation ID)

Q1) Is it possible to Add Dynamic Correlation ID value and inject this correlation ID in each http request header so backend pool will have correlation ID.
I see the option to set custom headers using Applicaiton gateway Rewrites->RuleSet->Rewrite Rule Configuration182084-header-value.png functionlity but not sure how to generate dynamic Correlation ID - is this allowed ?

Please suggest.






Q2) How to include this custom Correlation ID in logs so we can track the requests based on this Correlation ID ?
182085-appgatewaylogs.png

azure-application-gateway
header-value.png (148.9 KiB)
appgatewaylogs.png (129.3 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

ChaitanyaNaykodiMSFT-9638 avatar image
0 Votes"
ChaitanyaNaykodiMSFT-9638 answered SrinivasuluValleti-9007 commented

Hello @SrinivasuluValleti-9007, I got a response back from the team.

Overriding the value of x-appgw-trace-id is currently not supported, you can create a feedback item for this request on our feedback portal.

For now, you can pass the correlation-ID header to your backend pools. As you have APIM as your App Gateway's backend you can either forward the header to your backend server or use APIM policies to log information via Event Hub, you can find additional details here.

Hope this helps!


​​Please "Accept the answer" if the information helped you. This will help us and others in the community as well.


· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thank you @ChaitanyaNaykodiMSFT-9638 .

I understand this is a limitation from Application Gateway. I hope this will be supported in upcoming releases.

0 Votes 0 ·
ChaitanyaNaykodiMSFT-9638 avatar image
0 Votes"
ChaitanyaNaykodiMSFT-9638 answered

Hello @SrinivasuluValleti-9007, welcome to Microsoft Q&A forum.

As I understood from the question above, you are trying to add a Correlation ID as a HTTP header in your AppGw so that you can tarck each request to your Backend pool

Q1) Is it possible to Add Dynamic Correlation ID value and inject this correlation ID in each http request header so backend pool will have correlation ID.

If you want to use this Correlation ID to track the http request from your AppGw to your Backend pool. As per this documentation Application gateway inserts six additional headers to all requests before it forwards the requests to the backend. x-appgw-trace-id is one of the headers which is added. x-appgw-trace-id is a unique guid generated by application gateway for each client request and presented in the forwarded request to the backend pool member. The guid consists of 32 alphanumeric characters presented without dashes (for example: ac882cd65a2712a0fe1289ec2bb6aee7).

Q2) How to include this custom Correlation ID in logs so we can track the requests based on this Correlation ID?

You can use the x-appgw-trace-id header to correlate a request received by application gateway and initiated to a backend pool member via the transactionId property in Diagnostic Logs.

Hope this helps! Please let me know if you have any additional questions. Thank you!


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

SrinivasuluValleti-9007 avatar image
0 Votes"
SrinivasuluValleti-9007 answered ChaitanyaNaykodiMSFT-9638 commented

Thank you for your Response @ChaitanyaNaykodiMSFT-9638 .
In our case Before APP Gateway we have UI App which is generating Correlation ID in header , if this value is present in header then we have to use the Client provided Correlation ID to track all requests

UI -> App Gateway -> APIM
(here we have custom correlation ID ) (Here we have x-appgw-trace-id) (Here we have x-appgw-trace-id)

If Client doesn't provide Correlation ID then we are good with x-appgw-trace-id to track the requests in APIM and App Gateway but our requirement is to use Client Provided Correlation ID for tracking , if client doesn't provide then only we have to use x-appgw-trace-id.


We try to update x-appgw-trace-id in App Gateway but this is not working .
Here we try to set x-appgw-trace-id as custom header with some dummy value for testing , if this works then we can fill this dynamically from Custom Header(which is received from Client) .

Please suggest on how to override x-appgw-trace-id with custom value?
Please let me know if you need more inputs on this. Thanks in advance.

183418-image.png



image.png (58.1 KiB)
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hello @SrinivasuluValleti-9007, Thank you for providing additional details. I have reached to the team internally regarding this issue and will share an update as soon as I have a response. Thank you!

0 Votes 0 ·