You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/api-management/api-management-howto-api-inspector.md
+35-20Lines changed: 35 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@ services: api-management
5
5
author: dlepow
6
6
ms.service: azure-api-management
7
7
ms.topic: tutorial
8
-
ms.date: 05/05/2024
8
+
ms.date: 11/04/2024
9
9
ms.author: danlep
10
10
ms.custom: devdivchpfy22
11
11
---
@@ -36,11 +36,14 @@ In this tutorial, you learn how to:
36
36
37
37
## Trace a call in the portal
38
38
39
+
Follow these steps to trace an API request in the test console in the portal. This example assumes that you [imported](import-and-publish.md) a sample API in a previous tutorial. You can follow similar steps with a different API that you imported.
40
+
39
41
1. Sign in to the [Azure portal](https://portal.azure.com), and navigate to your API Management instance.
40
-
1. Select **APIs**.
41
-
1. Select **Demo Conference API** from your API list.
42
+
1. Select **APIs** > **APIs**.
43
+
1. Select **Petstore API** from your API list.
42
44
1. Select the **Test** tab.
43
-
1. Select the **GetSpeakers** operation.
45
+
1. Select the **Find pet by ID** operation.
46
+
1. In the *petId***Query parameter**, enter *1*.
44
47
1. Optionally check the value for the **Ocp-Apim-Subscription-Key** header used in the request by selecting the "eye" icon.
45
48
> [!TIP]
46
49
> You can override the value of **Ocp-Apim-Subscription-Key** by retrieving a key for another subscription in the portal. Select **Subscriptions**, and open the context menu (**...**) for another subscription. Select **Show/hide keys** and copy one of the keys. You can also regenerate keys if needed. Then, in the test console, select **+ Add header** to add an **Ocp-Apim-Subscription-Key** header with the new key value.
@@ -55,7 +58,7 @@ In this tutorial, you learn how to:
***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](transform-api.md), they'll appear here.
61
+
***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](transform-api.md), they appear here.
59
62
60
63
***Backend** - Shows the requests API Management sent to the API backend and the response it received.
61
64
@@ -69,25 +72,31 @@ In this tutorial, you learn how to:
69
72
70
73
## Enable tracing for an API
71
74
72
-
You can enable tracing for an API when making requests to API Management using `curl`, a REST client such as Visual Studio Code with the REST Client extension, or a client app.
75
+
The following high level steps are required to enable tracing for a request to API Management when using `curl`, a REST client such as Visual Studio Code with the REST Client extension, or a client app. Currently these steps must be followed using the [API Management REST API](/rest/api/apimanagement):
76
+
77
+
1. Obtain a token credential for tracing.
78
+
1. Add the token value in an `Apim-Debug-Authorization` request header to the API Management gateway.
79
+
1. Obtain a trace ID in the `Apim-Trace-Id` response header.
80
+
1. Retrieve the trace corresponding to the trace ID.
73
81
74
-
Enable tracing by the following steps using calls to the API Management REST API.
82
+
Detailed steps follow.
75
83
76
84
> [!NOTE]
77
-
> The following steps require API Management REST API version 2023-05-01-preview or later. You must be assigned the Contributor or higher role on the API Management instance to call the REST API.
85
+
> * These steps require API Management REST API version 2023-05-01-preview or later. You must be assigned the Contributor or higher role on the API Management instance to call the REST API.
86
+
> * For information about authenticating to the REST API, see [Azure REST API reference](/rest/api/azure).
78
87
79
-
1. Obtain trace credentials by calling the [List debug credentials](/rest/api/apimanagement/gateway/list-debug-credentials) API. Pass the gateway ID in the URI, or use "managed" for the instance's managed gateway in the cloud. For example, to obtain trace credentials for the managed gateway, use a call similar to the following:
88
+
1.**Obtain a token credential** - Call the API Management gateway's [List debug credentials](/rest/api/apimanagement/gateway/list-debug-credentials) API. In the URI, enter "managed" for the instance's managed gateway in the cloud, or the gateway ID for a self-hosted gateway. For example, to obtain trace credentials for the instance's managed gateway, use a request similar to the following:
80
89
81
90
```http
82
91
POST https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/managed/listDebugCredentials?api-version=2023-05-01-preview
83
92
```
84
93
85
-
In the request body, pass the full resource ID of the API that you want to trace, and specify `purposes` as `tracing`. By default the token credential returned in the response expires after 1 hour, but you can specify a different value in the payload.
94
+
In the request body, pass the full resource ID of the API that you want to trace, and specify `purposes` as `tracing`. By default the token credential returned in the response expires after 1 hour, but you can specify a different value in the payload. For example:
@@ -96,21 +105,27 @@ Enable tracing by the following steps using calls to the API Management REST API
96
105
97
106
```json
98
107
{
99
-
"token": "aid=api-name&p=tracing&ex=......."
108
+
"token": "aid=api-name&......."
100
109
}
101
110
```
102
111
103
-
1. To enable tracing for a request to the API Management gateway, send the token value in an `Apim-Debug-Authorization` header. For example, to trace a call to the demo conference API, use a call similar to the following:
112
+
1. **Add the token value in a request header** - To enable tracing for a request to the API Management gateway, send the token value in an `Apim-Debug-Authorization` header. For example, to trace a call to the Petstore API that you imported in a previous tutorial, you might use a request similar to the following:
1. Depending on the token, the response contains different headers:
109
-
* If the token is valid, the response includes an `Apim-Trace-Id` header whose value is the trace ID.
117
+
118
+
1. Depending on the token, the response contains one of the following headers:
119
+
* If the token is valid, the response includes an `Apim-Trace-Id` header whose value is the trace ID, similar to the following:
120
+
121
+
```http
122
+
Apim-Trace-Id: 0123456789abcdef....
123
+
```
124
+
110
125
* If the token is expired, the response includes an `Apim-Debug-Authorization-Expired` header with information about expiration date.
111
-
* If the token was obtained for wrong API, the response includes an `Apim-Debug-Authorization-WrongAPI` header with an error message.
126
+
* If the token was obtained for a different API, the response includes an `Apim-Debug-Authorization-WrongAPI` header with an error message.
112
127
113
-
1. To retrieve the trace, pass the trace ID obtained in the previous step to the [List trace](/rest/api/apimanagement/gateway/list-trace) API for the gateway. For example, to retrieve the trace for the managed gateway, use a call similar to the following:
128
+
1. **Retrieve the trace** - Pass the trace ID obtained in the previous step to the gateway's [List trace](/rest/api/apimanagement/gateway/list-trace) API. For example, to retrieve the trace for the managed gateway, use a request similar to the following:
114
129
115
130
```http
116
131
POST https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/managed/listTrace?api-version=2023-05-01-preview
@@ -120,7 +135,7 @@ Enable tracing by the following steps using calls to the API Management REST API
120
135
121
136
```json
122
137
{
123
-
"traceId": "<trace ID>"
138
+
"traceId": "0123456789abcdef...."
124
139
}
125
140
```
126
141
@@ -134,7 +149,7 @@ For information about customizing trace information, see the [trace](trace-polic
Copy file name to clipboardExpand all lines: includes/api-management-tracing-alert.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,10 +2,10 @@
2
2
author: dlepow
3
3
ms.service: azure-api-management
4
4
ms.topic: include
5
-
ms.date: 05/05/2024
5
+
ms.date: 11/04/2024
6
6
ms.author: danlep
7
7
---
8
8
> [!IMPORTANT]
9
-
> * API Management request tracing using the **Ocp-Apim-Trace** header in a request and using the value of the **Ocp-Apim-Trace-Location**response header is being deprecated.
10
-
> * To improve security, tracing can now be enabled at the level of an individual API by obtaining a time-limited token using the API Management REST API, and passing the token in a request to the gateway. For details, see [Enable tracing of an API](../articles/api-management/api-management-howto-api-inspector.md#enable-tracing-for-an-api).
9
+
> * API Management no longer supports subscriptions for tracing or the **Ocp-Apim-Trace** header.
10
+
> * To improve API security, tracing can now be enabled at the level of an individual API by obtaining a time-limited token using the API Management REST API, and passing the token in a request to the gateway. For details, see [Enable tracing of an API](../articles/api-management/api-management-howto-api-inspector.md#enable-tracing-for-an-api).
11
11
> * Take care when enabling tracing, as it can expose sensitive information in the trace data. Ensure that you have appropriate security measures in place to protect the trace data.
0 commit comments