Skip to content

Commit 8e50ff7

Browse files
author
gitName
committed
[APIM] Update tracing steps
1 parent 53b767d commit 8e50ff7

File tree

1 file changed

+35
-15
lines changed

1 file changed

+35
-15
lines changed

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

Lines changed: 35 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,14 @@ In this tutorial, you learn how to:
3636

3737
## Trace a call in the portal
3838

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+
3941
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.
4244
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*.
4447
1. Optionally check the value for the **Ocp-Apim-Subscription-Key** header used in the request by selecting the "eye" icon.
4548
> [!TIP]
4649
> 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.
@@ -69,25 +72,31 @@ In this tutorial, you learn how to:
6972

7073
## Enable tracing for an API
7174

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

74-
Enable tracing by the following steps using calls to the API Management REST API.
82+
Detailed steps follow
7583

7684
> [!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 [](). If you want to test the REST APIs, use the "Try It" functionality in the API Management REST API.
7887
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 [List debug credentials](/rest/api/apimanagement/gateway/list-debug-credentials) API. Pass the gateway ID for a self-hosted gateway in the URI, or specify "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:
8089

8190
```http
8291
POST https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/gateways/managed/listDebugCredentials?api-version=2023-05-01-preview
8392
```
8493
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:
8695
8796
```json
8897
{
8998
"credentialsExpireAfter": PT1H,
90-
"apiId": "<API resource ID>",
99+
"apiId": ""/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis/{apiName}",
91100
"purposes": ["tracing"]
92101
}
93102
```
@@ -100,17 +109,28 @@ Enable tracing by the following steps using calls to the API Management REST API
100109
}
101110
```
102111
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 call similar to the following:
104113
105114
```bash
106-
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=......."
115+
curl -v https://apim-hello-world.azure-api.net/pet/1 HTTP/1.1 -H "Ocp-Apim-Subscription-Key: <subscription-key>" -H "Apim-Debug-Authorization: aid=api-name&p=tracing&ex=......."
107116
```
117+
118+
> [!NOTE]
119+
> Information the user should notice even if skimming
120+
108121
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.
122+
* If the token is valid, the response includes an `Apim-Trace-Id` header whose value is the trace ID. For example:
123+
124+
```http
125+
[....]
126+
Apim-Trace-Id: 0123456789abcdef....
127+
[....]
128+
```
129+
110130
* If the token is expired, the response includes an `Apim-Debug-Authorization-Expired` header with information about expiration date.
111131
* If the token was obtained for wrong API, the response includes an `Apim-Debug-Authorization-WrongAPI` header with an error message.
112132
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:
133+
1. **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:
114134
115135
```http
116136
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 +140,7 @@ Enable tracing by the following steps using calls to the API Management REST API
120140
121141
```json
122142
{
123-
"traceId": "<trace ID>"
143+
"traceId": "0123456789abcdef...."
124144
}
125145
```
126146
@@ -134,7 +154,7 @@ For information about customizing trace information, see the [trace](trace-polic
134154
In this tutorial, you learned how to:
135155
136156
> [!div class="checklist"]
137-
> * Trace an example call
157+
> * Trace an example call in the test conosle
138158
> * Review request processing steps
139159
> * Enable tracing for an API
140160

0 commit comments

Comments
 (0)