How can I link API calls made through the APIM to my backend WebApp errors?

Benedikt Müller 0 Reputation points
2024-12-18T17:21:30.4733333+00:00

Hi,

Is there a possibility to link errors from my backend services (e.g. Webapp) to my API calls?

I currently track calls in ApiManagementGatewayLogs and my Webapps log into AppInsights (trace, exceptions).

What would be the best setup to display an API call fail with its associated backend error?

thanks

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

1 answer

Sort by: Most helpful
  1. hossein jalilian 9,310 Reputation points
    2024-12-18T17:24:33.14+00:00

    Thanks for posting your question in the Microsoft Q&A forum.

    Here's how to set up a system to display API call failures with their associated backend errors:

    1. Enable Application Insights integration with APIM
    2. Configure APIM to log request and response payloads:
      • Navigate to your API in the Azure portal
      • Under Settings, enable Frontend Request and Frontend Response logging
      • Set the number of payload bytes to log
    3. Use correlation IDs to link APIM and backend logs:
      • Implement a policy in APIM to generate and forward a correlation ID
      • Ensure your backend WebApp logs this correlation ID with each request
    4. Log backend errors in Application Insights:
      • Configure your WebApp to send detailed error logs to Application Insights
      • Include the correlation ID in these logs

    Please don't forget to close up the thread here by upvoting and accept it as an answer if it is 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.