Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No Traces in Azure API Response

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?

like image 871
Krishna Ramachandra Avatar asked Mar 29 '18 23:03

Krishna Ramachandra


3 Answers

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.

like image 69
Andy Yi Cui Avatar answered Nov 07 '22 14:11

Andy Yi Cui


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.

like image 40
zurebe-pieter Avatar answered Nov 07 '22 16:11

zurebe-pieter


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

like image 26
Krishna Ramachandra Avatar answered Nov 07 '22 16:11

Krishna Ramachandra