Skip to content

Commit a6ca8e4

Browse files
committed
expanded steps, edits
1 parent 071bf71 commit a6ca8e4

File tree

4 files changed

+29
-26
lines changed

4 files changed

+29
-26
lines changed

articles/api-management/api-management-howto-api-inspector.md

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ services: api-management
55
author: dlepow
66
ms.service: api-management
77
ms.topic: tutorial
8-
ms.date: 03/26/2024
8+
ms.date: 03/29/2024
99
ms.author: danlep
1010
ms.custom: devdivchpfy22
1111
---
@@ -19,8 +19,9 @@ This tutorial describes how to inspect (trace) request processing in Azure API M
1919
In this tutorial, you learn how to:
2020

2121
> [!div class="checklist"]
22-
> * Trace an example call
22+
> * Trace an example call in the test console
2323
> * Review request processing steps
24+
> * Enable tracing for an API
2425
2526
:::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":::
2627

@@ -35,7 +36,7 @@ In this tutorial, you learn how to:
3536

3637
[!INCLUDE [api-management-tracing-alert](../../includes/api-management-tracing-alert.md)]
3738

38-
## Trace a call
39+
## Trace a call in the portal
3940

4041
1. Sign in to the [Azure portal](https://portal.azure.com), and navigate to your API Management instance.
4142
1. Select **APIs**.
@@ -68,25 +69,22 @@ In this tutorial, you learn how to:
6869
> Each step also shows the elapsed time since the request is received by API Management.
6970
7071

71-
## Enable tracing using a REST client
72+
## Enable tracing for an API
7273

7374
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.
7475

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.
7977

8078
> [!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.
8280
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:
8482

8583
```http
8684
POST https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/managed/listDebugCredentials?api-version=2023-05-01-preview
8785
```
8886
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.
9088
9189
```json
9290
{
@@ -104,27 +102,31 @@ Enable tracing by the following flow using calls to the API Management REST API.
104102
}
105103
```
106104
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:
108106
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
107+
```bash
108+
curl -v GET https://apim-hello-world.azure-api.net/conference/speakers HTTP/1.1 -H "Ocp-Apim-Subscription-Key: <subscription-key>" -H "Apim-Debug-Authorization: aid=api-name&p=tracing&ex=......."
109+
```
110+
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.
112114
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:
114116
115117
```http
116118
POST https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/managed/listTrace?api-version=2023-05-01-preview
117119
```
118120
119-
with body
121+
In the request body, pass the trace ID obtained in the previous step.
120122
121123
```json
122124
{
123125
"traceId": "<trace ID>"
124126
}
125127
```
126128
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.
128130
129131
130132
For information about customizing trace information, see the [trace](trace-policy.md) policy.
@@ -136,6 +138,7 @@ In this tutorial, you learned how to:
136138
> [!div class="checklist"]
137139
> * Trace an example call
138140
> * Review request processing steps
141+
> * Enable tracing for an API
139142
140143
Advance to the next tutorial:
141144

articles/api-management/api-management-howto-create-subscriptions.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ When you publish APIs through Azure API Management, it's easy and common to secu
1717

1818
This article walks through the steps for creating subscriptions in the Azure portal.
1919

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+
2023
## Prerequisites
2124

2225
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:
3538
1. Optionally, choose if the subscription should be associated with a **User** and whether to send a notification for use with the developer portal.
3639
1. Select **Create**.
3740

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-
4141
:::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.":::
4242

4343
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.

includes/api-management-availability-tracing-v2-tiers.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ ms.author: danlep
77
---
88

99
> [!NOTE]
10-
> Currently, tracing in the test console isn't supported in the Basic v2 and Standard v2 tiers.
10+
> Currently, tracing of API requests isn't supported in the Basic v2 and Standard v2 tiers.

includes/api-management-tracing-alert.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ ms.topic: include
55
ms.date: 08/03/2022
66
ms.author: danlep
77
---
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

Comments
 (0)