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-debug-policies.md
+16-14Lines changed: 16 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -28,21 +28,18 @@ Azure API Management policies are a sequence of statements that address cross-cu
28
28
*[GitHub Copilot for Azure extension](https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-azure-github-copilot) - to create and explain policies
29
29
*[REST Client extension](https://marketplace.visualstudio.com/items?itemName=humao.rest-client) - to debug policies
30
30
31
-
<!-- Assume we need a step to install GH Copilot ext? -->
32
-
33
31
* An API Management instance. If you need to create one, see this [quickstart](vscode-create-service-instance.md).
34
32
35
-
<!-- Still can't use extension to create instance in v2 tiers? -->
36
-
37
33
* Import an API to your API Management instance. For example steps, see [Tutorial: Use the API Management Extension for Visual Studio Code to import and manage APIs](visual-studio-code-tutorial.md).
38
34
39
35
## Restrictions and limitations
40
36
41
-
* Policy debugging is currently supported in the API Management Developer tier
37
+
* Policy debugging is currently supported only in the API Management Developer tier.
42
38
43
-
* Policy debugging uses the built-in (service-level) all-access subscription (display name "Built-in all-access subscription") and enables tracing for the duration of the debugging session.
39
+
* Policy debugging uses the built-in (service-level) all-access subscription (display name "Built-in all-access subscription"). You must be a service owner to use this subscription.
44
40
45
-
## Create policies using GitHub Copilot
41
+
## Create a policy using GitHub Copilot
42
+
46
43
The Azure API Management extension integrates with GitHub Copilot for Azure to help you create a draft of a policy. With AI assistance, create and edit policies in a user-friendly way.
47
44
48
45
To create a policy:
@@ -52,6 +49,8 @@ To create a policy:
52
49
1. Select the policy scope that you want to work with.
53
50
* To create a policy that applies to all APIs in the instance, select **Global Policy**.
54
51
* To create a policy that applies to a specific API, under **APIs**, select the API, and then select **Policy**.
52
+
* To create a policy that applies to a specific API operation, select the operation, and then select **Policy**.
53
+
55
54
1. In the policy editor window that appears, right-click and select **Copilot** > **Draft APIM Policies**. The Copilot Chat window appears.
56
55
1. In the Copilot Chat window, enter a prompt in natural language to create a policy. Examples:
57
56
@@ -60,7 +59,7 @@ To create a policy:
60
59
```
61
60
62
61
```copilot-prompt
63
-
@azure Create a policy that sets the backend URL to https://mybackend.contoso.com and adds a header to the request
62
+
@azure Create a policy that sets the backend URL to https://mybackend.contoso.com and adds a custom header to the request
64
63
```
65
64
1. Copilot generates a policy draft in the chat window. You can refine the prompt if you want Copilot to change the output.
66
65
@@ -82,6 +81,8 @@ To receive an explanation:
82
81
1. Select the policy scope that you want to work with.
83
82
* To explain a policy that applies to all APIs in the instance, select **Global Policy**.
84
83
* To explain a policy that applies to a specific API, under **APIs**, select the API, and then select **Policy**.
84
+
* To explain a policy that applies to a specific API operation, select the operation, and then select **Policy**.
85
+
85
86
1. In the policy editor window that appears, right-click and select **Copilot** > **Explain APIM Policies**.
86
87
1. An overview and explanation of policies in the policy XML document are generated in the Copilot Chat window.
87
88
@@ -98,12 +99,12 @@ The Azure API Management extension for Visual Studio Code provides a debugging e
98
99
4. Select the API and operation to debug.
99
100
5. Right click on the operation and select **Start Policy Debugging**.
100
101
101
-
At this point, the extension starts to establish a debugging session with the API Management gateway. Check the progress in the **Debug Console** windows.
102
+
At this point, the extension starts to establish a debugging session with the API Management gateway. Check the progress in the **Debug Console** window.
102
103
103
104
:::image type="content" source="media/api-management-debug-policies/initiate-debugging-session.png" alt-text="Screenshot if initiating a policy debugging session in Visual Studio Code.":::
104
105
105
106
> [!NOTE]
106
-
> Starting a debugging session also enables request tracing during the session, to help you diagnose and solve issues.
107
+
> Starting a debugging session also enables request tracing for the duration of the session, to help you diagnose and solve issues.
107
108
108
109
### Send a test request
109
110
@@ -117,7 +118,8 @@ Modify the HTTP request in the editor according to your test scenario. Then clic
117
118
:::image type="content" source="media/api-management-debug-policies/rest-client.png" alt-text="Screenshot of sending a test request in Visual Studio Code.":::
118
119
119
120
### Debug policies
120
-
After the test HTTP request is sent, the extension opens the debugging window, which shows the effective policies of this operation and stop at the first effective policy.
121
+
122
+
After the test HTTP request is sent, the extension opens the debugging window, which shows the effective policies of this operation and stops at the first effective policy.
121
123
122
124
:::image type="content" source="media/api-management-debug-policies/main-window.png" alt-text="Screenshot of the debugging window in Visual Studio Code.":::
123
125
@@ -129,12 +131,12 @@ To follow the policy pipeline, you can single-step through individual policies o
129
131
130
132
If there is an error during policy execution, you will see the details of the error at the policy where it happened.
131
133
132
-
:::image type="content" source="media/api-management-debug-policies/exception.png" alt-text="Screenshot of a policy exception in Visual Studio Code.":::
134
+
Exit the debugging session by clicking the **Stop** button when you are finished.
133
135
134
-
To review the request trace, select the value of the `Ocp-Apim-Trace-Location` header that is provided in the HTTP response.
136
+
:::image type="content" source="media/api-management-debug-policies/exception.png" alt-text="Screenshot of a policy exception in Visual Studio Code.":::
135
137
136
138
> [!TIP]
137
-
> Exit the debugging session by clicking the **Stop** button when you are finished.
139
+
> To review the request trace, select the value of the `Ocp-Apim-Trace-Location` header that is provided in the HTTP response.
0 commit comments