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

Srinivasulu Valleti 26 Reputation points
2022-03-11T06:02:15.187+00:00

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 Virtual Network
Azure Virtual Network
An Azure networking service that is used to provision private networks and optionally to connect to on-premises datacenters.
2,762 questions
0 comments No comments
{count} votes

Accepted answer
  1. ChaitanyaNaykodi-MSFT 27,471 Reputation points Microsoft Employee Moderator
    2022-03-22T20:58:04.717+00:00

    Hello @Srinivasulu Valleti , 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.


2 additional answers

Sort by: Most helpful
  1. ChaitanyaNaykodi-MSFT 27,471 Reputation points Microsoft Employee Moderator
    2022-03-14T18:51:31.103+00:00

    Hello @Srinivasulu Valleti , 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!

    0 comments No comments

  2. Srinivasulu Valleti 26 Reputation points
    2022-03-15T21:07:56.67+00:00

    Thank you for your Response @ChaitanyaNaykodi-MSFT .
    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


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.