Tutorial: Debug your APIs using request tracing
This tutorial describes how to inspect (trace) request processing in Azure API Management to help you debug and troubleshoot your API.
In this tutorial, you learn how to:
- Trace an example call
- Review request processing steps
Prerequisites
- Learn the Azure API Management terminology.
- Complete the following quickstart: Create an Azure API Management instance.
- Complete the following tutorial: Import and publish your first API.
Verify allow tracing setting
The Allow tracing setting for the subscription used for your API must be enabled. If you're using the built-in all-access subscription, it's enabled by default. To verify in the portal, navigate to your API Management instance and select Subscriptions.
Trace a call
- Sign in to the Azure portal, and navigate to your API Management instance.
- Select APIs.
- Select Demo Conference API from your API list.
- Select the Test tab.
- Select the GetSpeakers operation.
- Confirm that the HTTP request header includes Ocp-Apim-Trace: True and a valid value for Ocp-Apim-Subscription-Key. If it isn't, select + Add Header to add the header.
- Select Send to make an API call.
Tip
If Ocp-Apim-Subscription-Key isn't automatically populated in the HTTP request, you can retrieve it in the portal. Select Subscriptions, and open the context menu (...) for your suscription. Select Show/hide keys. You can also regenerate keys if needed. Then, add a key to the header.
Review trace information
After the call completes, go to the Trace tab in the HTTP Response.
Select any of the following links to jump to detailed trace info: Inbound, Backend, Outbound.
Inbound - Shows the original request API Management received from the caller and the policies applied to the request. For example, if you added policies in Tutorial: Transform and protect your API, they will appear here.
Backend - Shows the requests API Management sent to the API backend and the response it received.
Outbound - Shows the policies applied to the response before sending back to the caller.
Tip
Each step also shows the elapsed time since the request is received by API Management.
On the Message tab, the ocp-apim-trace-location header shows the location of the trace data stored in Azure blob storage. If needed, go to this location to retrieve the trace.
Next steps
In this tutorial, you learned how to:
- Trace an example call
- Review request processing steps
Advance to the next tutorial: