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
For example, you might want to set a custom response header. Or, protect your backend API by configuring a rate limit policy, so that the API isn't overused by developers. These examples are a simple introduction to API Management policies. For more policy options, see [API Management policies](api-management-policies.md).
24
+
For example, you might want to set a custom response header. Or, configure a rate limit policy to protect your backend API, so developers don't overuse the API. These examples are a simple introduction to API Management policies. For more policy options, see [API Management policies](api-management-policies.md).
25
25
26
26
> [!NOTE]
27
27
> By default, API Management configures a global [`forward-request`](forward-request-policy.md) policy. The `forward-request` policy is needed for the gateway to complete a request to a backend service.
28
28
29
29
In this tutorial, you learn how to:
30
30
31
31
> [!div class="checklist"]
32
-
> * Transform an API to set a custom response header
33
-
> * Protect an API by adding a rate limit policy (throttling)
34
-
> * Test the transformations
32
+
> - Transform an API to set a custom response header
33
+
> - Protect an API by adding a rate limit policy, or *throttling*
34
+
> - Test the transformations
35
35
36
36
:::image type="content" source="media/transform-api/api-management-console-new.png" lightbox="media/transform-api/api-management-console-new.png" alt-text="Screenshot of API Management policies in the portal.":::
37
37
38
38
## Prerequisites
39
39
40
-
* Learn the [Azure API Management terminology](api-management-terminology.md).
41
-
* Understand the [concept of policies in Azure API Management](api-management-howto-policies.md).
42
-
* Complete the following quickstart: [Create an Azure API Management instance](get-started-create-service-instance.md). For this tutorial, we recommend that you use one of the classic or v2 tiers, for example, the Developer tier or the Basic v2 tier. The Consumption tier doesn't support all policies used in this tutorial.
43
-
* Also, complete the following tutorial: [Import and publish your first API](import-and-publish.md).
40
+
- Learn the [Azure API Management terminology](api-management-terminology.md).
41
+
- Understand the [concept of policies in Azure API Management](api-management-howto-policies.md).
42
+
- Complete the following quickstart: [Create an Azure API Management instance](get-started-create-service-instance.md). For this tutorial, we recommend that you use one of the classic or v2 tiers, for example, the Developer tier or the Basic v2 tier. The Consumption tier doesn't support all policies used in this tutorial.
43
+
- Complete the following tutorial: [Import and publish your first API](import-and-publish.md).
1. In your API Management service instance, select **APIs**.
52
-
1. Select **Swagger Petstore** from your API list.
53
-
1. Select the **Test** tab, on the top of the screen.
54
-
1. Select the **GET Finds pets by status** operation, and optionally select a different value of the *status***Query parameter**. Select **Send**.
51
+
1. In your API Management service instance, select **APIs** > **APIs**.
52
+
1. From your API list, select **Swagger Petstore**.
53
+
1. At the top of the screen, select **Test**.
54
+
1. Select the **GET Finds Pets by status** operation, and optionally select a different value of the *status***Query parameter**.
55
+
1. Select **Send**.
55
56
56
57
The original API response should look similar to the following response:
57
58
58
-
:::image type="content" source="media/transform-api/test-original-response-new.png" lightbox="media/transform-api/test-original-response-new.png" alt-text="Screenshot of the original API response in the portal.":::
59
+
:::image type="content" source="media/transform-api/test-original-response-new.png" lightbox="media/transform-api/test-original-response-new.png" alt-text="Screenshot of the original API response in the Azure portal.":::
59
60
60
61
## Transform an API to add a custom response header
61
62
@@ -74,19 +75,19 @@ This section shows you how to configure a custom response header using the `set-
74
75
75
76
:::image type="content" source="media/transform-api/set-http-header.png" alt-text="Screenshot of configuring the Set headers policy in the portal.":::
76
77
77
-
1. To configure the Set headers policy, do the following:
78
-
1. Under **Name**, enter **Custom**.
79
-
1. Under **Value**, select **+ Add value**. Enter *"My custom value"*.
80
-
1. Select **Save**.
78
+
1. To configure the Set headers policy:
79
+
80
+
1. Under **Name**, enter *Custom*.
81
+
1. Under **Value**, select **+ Add value**. Enter *\<My custom value>*.
82
+
1. Select **Save**.
81
83
82
-
1. After configuration, a **set-header** policy element appears in the **Outbound processing** section.
84
+
After configuration, a **set-header** policy element appears in the **Outbound processing** section.
83
85
84
86
:::image type="content" source="media/transform-api/set-policy.png" alt-text="Screenshot of the Set headers outbound policies in the portal.":::
85
87
86
-
87
88
## Protect an API by adding rate limit policy (throttling)
88
89
89
-
This section shows how to add protection to your backend API by configuring rate limits, so that the API isn't overused by developers. This example shows how to configure the `rate-limit-by-key` policy using the code editor. In this example, the limit is set to three calls per 15 seconds. After 15 seconds, a developer can retry calling the API.
90
+
This section shows how to add protection to your backend API by configuring rate limits, so that developers don't overuse the API. This example shows how to configure the `rate-limit-by-key` policy using the code editor. In this example, the limit is set to three calls per 15 seconds. After 15 seconds, a developer can retry calling the API.
90
91
91
92
> [!NOTE]
92
93
> This policy isn't supported in the Consumption tier.
@@ -96,23 +97,22 @@ This section shows how to add protection to your backend API by configuring rate
96
97
97
98
:::image type="content" source="media/transform-api/inbound-policy-code.png" lightbox="media/transform-api/inbound-policy-code.png" alt-text="Screenshot of navigating to inbound policy code editor in the portal.":::
98
99
99
-
1. Position the cursor inside the **`<inbound>`** element on a blank line. Then, select **Show snippets** at the top-right corner of the screen.
100
+
1. Position the cursor inside the **\<inbound>** element on a blank line. Then, select **Show snippets** at the top-right corner of the screen.
100
101
101
102
:::image type="content" source="media/transform-api/show-snippets-2.png" alt-text="Screenshot of selecting show snippets in inbound policy editor in the portal.":::
102
103
103
104
1. In the right window, under **Access restriction policies**, select **Limit call rate per key**.
104
105
105
-
The **`<rate-limit-by-key />`** element is added at the cursor.
106
+
The **\<rate-limit-by-key />** element is added at the cursor.
106
107
107
108
:::image type="content" source="media/transform-api/limit-call-rate-per-key.png" alt-text="Screenshot of inserting limit call rate per key policy in the portal.":::
108
109
109
-
1. Modify your **`<rate-limit-by-key />`** code in the **`<inbound>`** element to the following code. Then select **Save**.
110
+
1. Modify your **\<rate-limit-by-key />** code in the **`<inbound>`** element to the following code. Then select **Save**.
0 commit comments