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
+21-18Lines changed: 21 additions & 18 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: api-management
7
7
ms.topic: tutorial
8
-
ms.date: 03/26/2024
8
+
ms.date: 03/29/2024
9
9
ms.author: danlep
10
10
ms.custom: devdivchpfy22
11
11
---
@@ -19,8 +19,9 @@ This tutorial describes how to inspect (trace) request processing in Azure API M
19
19
In this tutorial, you learn how to:
20
20
21
21
> [!div class="checklist"]
22
-
> * Trace an example call
22
+
> * Trace an example call in the test console
23
23
> * Review request processing steps
24
+
> * Enable tracing for an API
24
25
25
26
:::image type="content" source="media/api-management-howto-api-inspector/api-inspector-002.png" alt-text="Screenshot showing the API inspector." lightbox="media/api-management-howto-api-inspector/api-inspector-002.png":::
26
27
@@ -35,7 +36,7 @@ In this tutorial, you learn how to:
1. Sign in to the [Azure portal](https://portal.azure.com), and navigate to your API Management instance.
41
42
1. Select **APIs**.
@@ -68,25 +69,22 @@ In this tutorial, you learn how to:
68
69
> Each step also shows the elapsed time since the request is received by API Management.
69
70
70
71
71
-
## Enable tracing using a REST client
72
+
## Enable tracing for an API
72
73
73
74
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.
74
75
75
-
> [!IMPORTANT]
76
-
> API Management request tracing is no longer enabled by setting the **Ocp-Apim-Trace** header in a request and using the value of the **Ocp-Apim-Trace-Location** header in the response to retrieve the trace.
77
-
78
-
Enable tracing by the following flow using calls to the API Management REST API.
76
+
Enable tracing by the following steps using calls to the API Management REST API.
79
77
80
78
> [!NOTE]
81
-
> The following steps require API Management REST API version 2023-05-01-preview or later.
79
+
> 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.
82
80
83
-
1. Obtain trace credentials by calling the [List debug credentials](/rest/api/apimanagement/gateway/list-debug-credentials) API. Pass the gateway resource ID in the URI, or use "managed" for the instance's managed gateway. for cloud in URI, and API that you want to trace in payload. For example:
81
+
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:
84
82
85
83
```http
86
84
POST https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/managed/listDebugCredentials?api-version=2023-05-01-preview
87
85
```
88
86
89
-
Pass the full resource ID of the API in the payload, 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.
87
+
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.
90
88
91
89
```json
92
90
{
@@ -104,27 +102,31 @@ Enable tracing by the following flow using calls to the API Management REST API.
104
102
}
105
103
```
106
104
107
-
1. To enable tracing, send the token value in an `Apim-Debug-Authorization` header of an API request.
105
+
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:
108
106
109
-
* If the token is valid, the response contains an `Apim-Trace-Id` header whose value is the trace ID.
110
-
* If the token is expired, the response contains an `Apim-Debug-Authorization-Expired` header with information about expiration date.
111
-
* If the token was obtained for wrong API, the response contains an `Apim-Debug-Authorization-WrongAPI` header with an error message
1. Depending on the token, the response contains different headers:
111
+
* If the token is valid, the response includes an `Apim-Trace-Id` header whose value is the trace ID.
112
+
* If the token is expired, the response includes an `Apim-Debug-Authorization-Expired` header with information about expiration date.
113
+
* If the token was obtained for wrong API, the response includes an `Apim-Debug-Authorization-WrongAPI` header with an error message.
112
114
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:
115
+
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:
114
116
115
117
```http
116
118
POST https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/managed/listTrace?api-version=2023-05-01-preview
117
119
```
118
120
119
-
with body
121
+
In the request body, pass the trace ID obtained in the previous step.
120
122
121
123
```json
122
124
{
123
125
"traceId": "<trace ID>"
124
126
}
125
127
```
126
128
127
-
The response body contains the trace data for the previous API request to the gateway.
129
+
The response body contains the trace data for the previous API request to the gateway. The trace is similar to the trace you can see by tracing a call in the portal's test console.
128
130
129
131
130
132
For information about customizing trace information, see the [trace](trace-policy.md) policy.
@@ -136,6 +138,7 @@ In this tutorial, you learned how to:
Copy file name to clipboardExpand all lines: articles/api-management/api-management-howto-create-subscriptions.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
@@ -17,6 +17,9 @@ When you publish APIs through Azure API Management, it's easy and common to secu
17
17
18
18
This article walks through the steps for creating subscriptions in the Azure portal.
19
19
20
+
> [!IMPORTANT]
21
+
> The **Allow tracing** setting in subscriptions to enable debug traces is deprecated. To improve security, tracing can now be enabled for specific API requests to API Management. [Learn more](api-management-howto-api-inspector.md#enable-tracing-for-an-api)
22
+
20
23
## Prerequisites
21
24
22
25
To take the steps in this article, the prerequisites are as follows:
@@ -35,9 +38,6 @@ To take the steps in this article, the prerequisites are as follows:
35
38
1. Optionally, choose if the subscription should be associated with a **User** and whether to send a notification for use with the developer portal.
36
39
1. Select **Create**.
37
40
38
-
> [!IMPORTANT]
39
-
> The **Allow tracing** setting in subscriptions is deprecated. Tracing can now be enabled for specific APIs. [Learn more](api-management-howto-api-inspector.md)
40
-
41
41
:::image type="content" source="media/api-management-howto-create-subscriptions/create-subscription.png" alt-text="Screenshot showing how to create an API Management subscription in the portal.":::
42
42
43
43
After you create the subscription, it appears in the list on the **Subscriptions** page. Two API keys are provided to access the APIs. One key is primary, and one is secondary.
Copy file name to clipboardExpand all lines: includes/api-management-tracing-alert.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@ ms.topic: include
5
5
ms.date: 08/03/2022
6
6
ms.author: danlep
7
7
---
8
-
> [!WARNING]
9
-
> *Only allow tracing on subscriptions intended for debugging purposes. Sharing subscription keys with tracing allowed with unauthorized users could lead to disclosure of sensitive information contained in tracing logs such as keys, access tokens, passwords, internal hostnames, and IP addresses.
10
-
> * API Management automatically disables tracing 1 hour after it's enabled on a subscription.
11
-
8
+
> [!IMPORTANT]
9
+
> *API Management request tracing can no longer be enabled by setting the **Ocp-Apim-Trace** header in a request and using the value of the **Ocp-Apim-Trace-Location** header in the response to retrieve the trace.
10
+
> *To improve security, tracing is now 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 later in this tutorial.
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