How to create a correlation id using either an id from the message or x-appgw-trace-id

Niels Beukenkamp 25 Reputation points
2023-07-11T11:31:52.6366667+00:00

In our setting we use correlation ID's for everything.

My vision of this is the following:

  1. Application Gateway checks if the request (from the consumer) already contains a header called "correlation-id"
  2. If this header exists, forward this header to the backend under the header "correlation-id" and include it in the response
  3. If this header does not exist, create it ("correlation-id") using the  value generated by the AG in the field x-appgw-trace-id

How would we be able to do this?

Azure Application Gateway
Azure Application Gateway
An Azure service that provides a platform-managed, scalable, and highly available application delivery controller as a service.
1,213 questions
{count} vote

Accepted answer
  1. ChaitanyaNaykodi-MSFT 27,471 Reputation points Microsoft Employee Moderator
    2023-07-12T00:50:59.5233333+00:00

    @Niels Beukenkamp

    Thank you for reaching out.

    Based on your points mentioned above.

    If this header does not exist, create it ("correlation-id") using the  value generated by the AG in the field

    Currently assigning the x-appgw-trace-id value to a custom-header is not supported in Application Gateway. If you wish to add this as a feature, it will help if you can create a feedback item for this request on our feedback portal.

    Alternatively, I realized you question was tagged with Azure API Management service. If you are using Azure APIM service in your set-up. You can use APIM policies to add a correlation id to your request as described in your points above . You can refer to this sample described here.

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


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

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

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.