No Traces in Azure API Response
Asked Answered
P

4

14

The Flag Ocp-Apim-Tracehas been set to true.

The API Response displays this information under the Trace Tab:

Trace location was not specified in the response or trace log is not available.

Yet no traces are available. How does one resolve this?

Partida answered 29/3, 2018 at 23:56 Comment(0)
K
14

To enable trace, you need to include "Ocp-Apim-Trace" and "Ocp-Apim-Subscription-Key" in request header.

If the API does not require subscription, you can still get admin subscription key in developer portal. This enforces that only admin can get tracing log. To get admin subscription key if you are an admin, go to Developer Portal -> Profile -> find your target API and copy the key.

Kinlaw answered 17/4, 2018 at 19:11 Comment(3)
should be marked as answer because it also tells you how to get the subscription key of an admin user when the API itself does not require subscriptionDurkin
learn.microsoft.com/en-us/azure/api-management/…Slaughter
"Make sure to include an HTTP header named Ocp-Apim-Trace with the value set to true." learn.microsoft.com/en-us/azure/api-management/…Slaughter
E
3

The Ocp-Apim-Trace feature enables you to specify whether or not APIM should generate a trace file on blob storage.

Setting the header to 'true' within Postman for example, will give you back a HTTP Header in the response called Ocp-Apim-Trace-Location. This will contain the URL to your trace file, which you can open in any browser.

You might want to install a plugin/extension to be able to format JSON files properly in order to make it easy to read.

Expurgatory answered 30/3, 2018 at 8:25 Comment(2)
Just putting Ocp-Apim-Trace into postman does not,( maybe for me and how my APIM is setup), return any such http location. Is there setup required in Azure to return such a location?Competitor
@ΩmegaMan you need to have an administrator subscription key to see the trace files being returned. Sorry for not mentioning this earlier.Expurgatory
P
2

Just setting the flag Ocp-Apim-Trace to true will not suffice. One needs to set the subscription key as well as per this doc.

https://learn.microsoft.com/en-us/azure/api-management/api-management-advanced-policies#Trace

So, for API's which do not have a subscription key, not sure how one can get the traces

Partida answered 30/3, 2018 at 14:36 Comment(1)
Mark this as the answer, which is ok to do, to close the issue.Competitor
P
1

You need to enable "Allow tracking" on the subscription whose key you are using and then pass the header Ocp-Apim-Trace to true.

Parker answered 2/7, 2023 at 17:21 Comment(1)
Probably a spell check issue here. The indicated checkbox is actually labeled "Allow Tracing" not "Allow Tracking"Composure

© 2022 - 2024 — McMap. All rights reserved.