APIM ID Log

Upasana Ghosh 351 Reputation points
2023-01-03T11:18:44.19+00:00

we need to be able to trace requests that passed through APIM.
In my knowledge a standard way would be by using something like a correlation-id.
i have checked this doc : https://learn.microsoft.com/en-us/azure/api-management/api-management-policy-expressions

is there any other way to add corelation id so that in logs it can be traced ?

Azure API Management
Azure API Management
An Azure service that provides a hybrid, multi-cloud management platform for APIs.
2,464 questions
Azure Policy
Azure Policy
An Azure service that is used to implement corporate governance and standards at scale for Azure resources.
1,019 questions
0 comments No comments
{count} votes

Accepted answer
  1. JananiRamesh-MSFT 29,276 Reputation points
    2023-01-03T15:35:48.963+00:00

    Hi @Upasana Ghosh Thanks for reaching out. Yes, you can use a correlation ID to trace requests through Azure API Management.
    To add a correlation ID to requests passing through APIM, you can use a policy expression in the inbound section of your API's policy. Here's an example of how you can do this:

    Navigate to inbound policy on API or Operation layer, do the following changes:

    • Create a GUID for your API request,
    • Use <set-header> to create a GUID for the ‘correlation-id’
    • Add a <trace> policy to trace the information inside your APIM Application Insights.

    275772-image.png

    You could refer to the statement of above <message> and <metadata> from this link: https://learn.microsoft.com/en-us/azure/api-management/api-management-advanced-policies#elements-15

    275640-image.png

    do let me know incase of further queries, I would be happy to assist you.

    Please 'Accept as answer' and ‘Upvote’ if it helped so that it can help others in the community looking for help on similar topics.

    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.