Logging Request and Response Data in Azure API Management with Application Insights

Vinayak Kanchan 20 Reputation points
2025-02-06T05:47:49.22+00:00

How can complete request and response data of an API be logged in Application Insights when the API is hosted on Azure API Management?

Azure API Management
Azure API Management
An Azure service that provides a hybrid, multi-cloud management platform for APIs.
2,448 questions
0 comments No comments
{count} votes

Accepted answer
  1. Khadeer Ali 5,990 Reputation points Microsoft External Staff Moderator
    2025-02-06T14:56:23.8233333+00:00

    @Vinayak Kanchan ,

    Welcome to Microsoft Q&A Platform!

    Thanks for reaching out. To log all request and response data of an API hosted on Azure API Management in Application Insights, you can use the log-to-eventhub policy. This lets you send details from the request and response to an Azure Event Hub for logging and monitoring.

    Here’s how you do it:

    1. Set up a connection between Application Insights and your API Management service using the Azure portal or REST API.
    2. Turn on Application Insights logging for your API(s) by going to your API Management service instance, picking the API, and enabling diagnostics logs.
    3. Set up the log-to-eventhub policy in your API Management service to capture the entire HTTP request and response message. This way, you can send that message to a third-party service or store it for auditing and analytics.

    By following these steps, you’ll ensure that the complete request and response data is logged effectively.

    References:

    Hope this helps. Do let us know if you have any further queries.


    If this answers your query, do click Accept Answer and Yes for "Was this answer helpful." And if you have any further questions, let us know.

    1 person found this answer helpful.

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.