Skip to content

Commit a232992

Browse files
committed
Resolved conflict
2 parents 81dfe10 + 8e8e800 commit a232992

File tree

736 files changed

+10174
-6353
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

736 files changed

+10174
-6353
lines changed

.openpublishing.redirection.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,16 @@
379379
"redirect_url": "/previous-versions/azure/partner-solutions/logzio/troubleshoot",
380380
"redirect_document_id": false
381381
},
382+
{
383+
"source_path": "articles/security/fundamentals/ocsp-sha-1-sunset.md",
384+
"redirect_url": "/azure/security/fundamentals/azure-CA-details",
385+
"redirect_document_id": false
386+
},
387+
{
388+
"source_path": "articles/security/fundamentals/tls-certificate-changes.md",
389+
"redirect_url": "/azure/security/fundamentals/azure-CA-details",
390+
"redirect_document_id": false
391+
},
382392
{
383393
"source_path": "articles/event-grid/event-schema-storage-actions.md",
384394
"redirect_url": "/azure/storage-actions/overview",
@@ -2294,6 +2304,11 @@
22942304
"redirect_url": "/previous-versions/azure/public-multi-access-edge-compute-mec/tutorial-create-vm-using-go-sdk",
22952305
"redirect_document_id": false
22962306
},
2307+
{
2308+
"source_path_from_root": "/articles/app-service/manage-disaster-recovery.md",
2309+
"redirect_url": "/azure/architecture/web-apps/guides/multi-region-app-service/multi-region-app-service",
2310+
"redirect_document_id": false
2311+
},
22972312
{
22982313
"source_path_from_root": "/articles/public-multi-access-edge-compute-mec/tutorial-create-vm-using-python-sdk.md",
22992314
"redirect_url": "/previous-versions/azure/public-multi-access-edge-compute-mec/tutorial-create-vm-using-python-sdk",
@@ -6723,6 +6738,11 @@
67236738
"source_path": "articles/notification-hubs/xamarin-notification-hubs-push-notifications-android-gcm.md",
67246739
"redirect_url": "/dotnet/maui/data-cloud/push-notifications",
67256740
"redirect_document_id": false
6741+
},
6742+
{
6743+
"source_path": "articles/storage/files/geo-redundant-storage-for-large-file-shares.md",
6744+
"redirect_url": "/azure/storage/files/files-redundancy",
6745+
"redirect_document_id": false
67266746
}
67276747
]
67286748
}

articles/api-management/TOC.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@
263263
href: set-edit-policies.md
264264
- name: Author policies using Microsoft Copilot in Azure
265265
href: /azure/copilot/author-api-management-policies?toc=%2Fazure%2Fapi-management%2Ftoc.json&bc=/azure/api-management/breadcrumb/toc.json
266-
- name: Debug policies in VS Code
266+
- name: Create and debug policies in VS Code
267267
href: api-management-debug-policies.md
268268
- name: Policy expressions
269269
href: api-management-policy-expressions.md

articles/api-management/api-management-debug-policies.md

Lines changed: 99 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,140 @@
11
---
2-
title: Debug Azure API Management policies in Visual Studio Code | Microsoft Docs
3-
description: Learn how to debug Azure API Management Policies using the Azure API Management Visual Studio Code extension
2+
title: Create and debug Azure API Management policies in VS Code
3+
description: Learn how to create, understand, and debug Azure API Management Policies with Copilot assistance using the Azure API Management Visual Studio Code extension.
44
author: dlepow
55
ms.service: azure-api-management
66
ms.topic: how-to
7-
ms.date: 09/22/2020
7+
ms.date: 03/27/2025
88
ms.author: danlep
9+
ms.collection: ce-skilling-ai-copilot
910
---
1011

11-
# Debug Azure API Management policies in Visual Studio Code
12+
# Create, understand, and debug Azure API Management policies in Visual Studio Code
1213

13-
[!INCLUDE [api-management-availability-developer](../../includes/api-management-availability-developer.md)]
14+
[!INCLUDE [api-management-availability-all-tiers](../../includes/api-management-availability-all-tiers.md)]
1415

15-
[Policies](api-management-policies.md) in Azure API Management provide powerful capabilities that help API publishers address cross-cutting concerns such as authentication, authorization, throttling, caching, and transformation. Policies are a collection of statements that are executed sequentially on the request or response of an API.
16+
This article explains how to use the [Azure API Management Extension for Visual Studio Code](https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-apimanagement) to create, understand, and debug Azure API Management policies with AI assistance from [GitHub Copilot for Azure](/azure/developer/github-copilot-azure/introduction).
1617

17-
This article describes how to debug API Management policies using the [Azure API Management Extension for Visual Studio Code](https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-apimanagement).
18+
Azure API Management [policies](api-management-howto-policies.md) are a sequence of statements that address cross-cutting concerns like authentication, authorization, throttling, caching, and transformation, applied to API requests or responses.
1819

1920
## Prerequisites
2021

21-
* Create an API Management Developer-tier instance by following this [quickstart](get-started-create-service-instance.md) first.
22+
* [Visual Studio Code](https://code.visualstudio.com/) and the latest version of [Azure API Management Extension for Visual Studio Code](https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-apimanagement).
2223

23-
* Install [Visual Studio Code](https://code.visualstudio.com/) and the latest version of [Azure API Management Extension for Visual Studio Code](https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-apimanagement).
24+
* The following extensions are needed for the specified scenarios:
25+
26+
* [GitHub Copilot for Azure extension](https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-azure-github-copilot) - to create and explain policies
27+
* [REST Client extension](https://marketplace.visualstudio.com/items?itemName=humao.rest-client) - for policy debugging
28+
29+
* An API Management instance. If you need to create one, see this [quickstart](vscode-create-service-instance.md).
2430

2531
* 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).
2632

2733
## Restrictions and limitations
2834

29-
* This feature uses the built-in (service-level) all-access subscription (display name "Built-in all-access subscription") for debugging.
35+
* Policy debugging is currently supported only in the API Management Developer tier.
36+
37+
* 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.
38+
39+
## Create a policy using GitHub Copilot for Azure
40+
41+
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.
42+
43+
To create a policy:
44+
45+
1. Open the API Management extension in Visual Studio Code.
46+
1. Select the API Management instance you want to work with.
47+
1. Select the policy scope that you want to work with.
48+
* To create a policy that applies to all APIs in the instance, select **Global Policy**.
49+
* To create a policy that applies to a specific API, under **APIs**, select the API, and then select **Policy**.
50+
* To create a policy that applies to a specific API operation, select the operation, and then select **Policy**.
51+
52+
1. In the policy editor window that appears, right-click and select **Copilot** > **Draft APIM Policies**. The Copilot Chat window appears.
53+
1. In the Copilot Chat window, enter a prompt in natural language to create a policy. Examples:
54+
55+
```copilot-prompt
56+
@azure I want to limit requests to 100 calls per minute
57+
```
58+
59+
```copilot-prompt
60+
@azure Create a policy that sets the backend URL to https://mybackend.contoso.com and adds a custom header to the request
61+
```
62+
1. Copilot generates a policy draft in the chat window. You can refine the prompt if you want Copilot to change the output.
63+
64+
1. When you're ready, select the **Copy** button to copy the policy to the clipboard, or select **Apply in Editor** to insert the policy in the editor window. If you are satisfied with the change in the policy XML, select **Keep**.
65+
66+
:::image type="content" source="media/api-management-debug-policies/draft-policy.gif" alt-text="Animation showing drafting of an API Management policy in VS Code.":::
67+
68+
> [!TIP]
69+
> Check in the **Problems** window for explanation of any issues in the policy XML.
70+
71+
## Explain a policy using GitHub Copilot for Azure
3072
31-
[!INCLUDE [api-management-tracing-alert](../../includes/api-management-tracing-alert.md)]
73+
Copilot can help explain an existing policy in your API Management instance.
3274
33-
## Initiate a debugging session
75+
To receive an explanation:
3476
35-
1. Launch Visual Studio Code
36-
2. Navigate to the API Management extension under Azure extensions
37-
3. Find the API Management instance to debug
38-
4. Find the API and operation to debug
39-
5. Right click on the operation and select **Start policy debugging**
77+
1. Open the API Management extension in Visual Studio Code.
78+
1. Select the API Management instance you want to work with.
79+
1. Select the policy scope that you want to work with.
80+
* To explain a policy that applies to all APIs in the instance, select **Global Policy**.
81+
* To explain a policy that applies to a specific API, under **APIs**, select the API, and then select **Policy**.
82+
* To explain a policy that applies to a specific API operation, select the operation, and then select **Policy**.
4083
41-
At this point, the extension will try to initiate and establish a debugging session with the API Management gateway.
84+
1. In the policy editor window that appears, right-click and select **Copilot** > **Explain APIM Policies**.
85+
1. An overview and explanation of policies in the policy XML document are generated in the Copilot Chat window.
4286
43-
![initiate debugging](media/api-management-debug-policies/initiate-debugging-session.png)
87+
:::image type="content" source="media/api-management-debug-policies/draft-policy.gif" alt-text="Animation showing explanation of an API Management policy in VS Code.":::
4488
45-
## Send a test request
46-
When the debugging session is established, the extension will open a new editor that allows us to create and send a test HTTP request to this operation leveraging the [REST Client extension](https://marketplace.visualstudio.com/items?itemName=humao.rest-client).
89+
## Debug policies using the VS Code extension
4790
48-
You will notice the **Ocp-Apim-Debug** header has already been added to the request. This header is required and the value must be set to the service-level, all-access subscription key to trigger the debugging functionality in the API Management gateway.
91+
The Azure API Management extension for Visual Studio Code provides a debugging experience that allows you to step through the policy pipeline or set a breakpoint when you send a request to the gateway.
4992
50-
Modify the HTTP request in the editor according to your test scenario. Then click **send request** to send the test request to the API Management gateway.
93+
### Initiate a debugging session
5194
52-
![send a test request](media/api-management-debug-policies/rest-client.png)
95+
1. Open the API Management extension in Visual Studio Code.
96+
3. Select the API Management instance to debug.
97+
4. Select the API and operation to debug.
98+
5. Right click on the operation and select **Start Policy Debugging**.
5399
54-
## Debug policies
55-
After the test HTTP request is sent, the extension will open the debugging window showing the effective policies of this operation and stop at the first effective policy.
100+
At this point, the extension starts to establish a debugging session with the API Management gateway. Check the progress in the **Debug Console** window.
56101
57-
![debug policies](media/api-management-debug-policies/main-window.png)
102+
:::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.":::
103+
104+
> [!NOTE]
105+
> Starting a debugging session also enables request tracing for the duration of the session, to help you diagnose and solve issues.
106+
107+
### Send a test request
108+
109+
When the debugging session is established, the REST Client extension opens a new editor that allows you to create and send a test HTTP request to the gateway.
110+
111+
The **Ocp-Apim-Debug** header is added automatically to the request. This header is required and the value must be set to the service-level, all-access subscription key to trigger the debugging functionality in the API Management gateway.
112+
113+
Modify the HTTP request in the editor according to your test scenario. Then click **Send Request** to send the test request to the API Management gateway.
114+
115+
116+
:::image type="content" source="media/api-management-debug-policies/rest-client.png" alt-text="Screenshot of sending a test request in Visual Studio Code.":::
117+
118+
### Debug policies
119+
120+
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+
122+
:::image type="content" source="media/api-management-debug-policies/main-window.png" alt-text="Screenshot of the debugging window in Visual Studio Code.":::
58123
59124
To follow the policy pipeline, you can single-step through individual policies or set a breakpoint at a policy and step directly to that policy.
60125
61-
In the **Variables** panel, you can inspect values of system-created and user-created variables. In the **Breakpoints** panel, you can see the list of all breakpoints that have been set. In the **Call Stack** panel, you can see the current effective policy scope.
126+
* In the **Variables** panel, inspect values of system-created and user-created variables.
127+
* In the **Breakpoints** panel, view the list of all breakpoints that have been set.
128+
* In the **Call Stack** panel, view the current effective policy scope.
62129
63130
If there is an error during policy execution, you will see the details of the error at the policy where it happened.
64131
65-
![exceptions](media/api-management-debug-policies/exception.png)
132+
Exit the debugging session by clicking the **Stop** button when you are finished.
66133
67-
> [!TIP]
68-
> Remember to exit the debug session by clicking the **Stop** button when you are finished.
134+
:::image type="content" source="media/api-management-debug-policies/exception.png" alt-text="Screenshot of a policy exception in Visual Studio Code.":::
69135
136+
> [!TIP]
137+
> To review the request trace, select the value of the `Ocp-Apim-Trace-Location` header that is provided in the HTTP response.
70138
71139
## Related content
72140

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ To help automate these steps with the [Visual Studio Code REST Client](https://m
172172
@requestBody = // Data to send
173173
@tenantId = // Tenant ID
174174
175-
POST https://login.microsoftonline.com/{{tenandId}}/oauth2/token
175+
POST https://login.microsoftonline.com/{tenantId}/oauth2/token
176176
content-type: application/x-www-form-urlencoded
177177
178178
grant_type=client_credentials&client_id={{clientId}}&client_secret={{clientSecret}}&resource=https%3A%2F%2Fmanagement.azure.com%2F

articles/api-management/api-management-howto-cache-external.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ To complete this tutorial, you need to:
4141

4242
+ [Create an Azure API Management instance](get-started-create-service-instance.md)
4343
+ Understand [caching in Azure API Management](api-management-howto-cache.md)
44-
+ Have an [Azure Cache for Redis](../azure-cache-for-redis/quickstart-create-redis.md), [Azure Managed Redis](../azure-cache-for-redis/quickstart-create-managed-redis.md), or another Redis-compatible cache available.
44+
+ Have an [Azure Cache for Redis](../azure-cache-for-redis/quickstart-create-redis.md), [Azure Managed Redis](../redis/quickstart-create-managed-redis.md), or another Redis-compatible cache available.
4545

4646
> [!IMPORTANT]
4747
> Azure API Management uses a Redis connection string to connect to the cache. If you use Azure Cache for Redis or Azure Managed Redis, enable access key authentication in your cache to use a connection string. Currently, you can't use Microsoft Entra authentication to connect Azure API Management to Azure Cache for Redis or Azure Managed Redis.

articles/api-management/azure-openai-enable-semantic-caching.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ ms.collection: ce-skilling-ai-copilot
1515

1616
[!INCLUDE [api-management-availability-all-tiers](../../includes/api-management-availability-all-tiers.md)]
1717

18-
Enable semantic caching of responses to Azure OpenAI API requests to reduce bandwidth and processing requirements imposed on the backend APIs and lower latency perceived by API consumers. With semantic caching, you can return cached responses for identical prompts and also for prompts that are similar in meaning, even if the text isn't the same. For background, see [Tutorial: Use Azure Cache for Redis as a semantic cache](../azure-cache-for-redis/cache-tutorial-semantic-cache.md).
18+
Enable semantic caching of responses to Azure OpenAI API requests to reduce bandwidth and processing requirements imposed on the backend APIs and lower latency perceived by API consumers. With semantic caching, you can return cached responses for identical prompts and also for prompts that are similar in meaning, even if the text isn't the same. For background, see [Tutorial: Use Azure Cache for Redis as a semantic cache](../redis/tutorial-semantic-cache.md).
1919

2020
> [!NOTE]
2121
> The configuration steps in this article enable semantic caching for Azure OpenAI APIs. These steps can be generalized to enable semantic caching for corresponding large language model (LLM) APIs available through the [Azure AI Model Inference API](/azure/ai-studio/reference/reference-model-inference-api).
@@ -27,9 +27,9 @@ Enable semantic caching of responses to Azure OpenAI API requests to reduce band
2727
* Chat Completion API - Deployment used for API consumer calls
2828
* Embeddings API - Deployment used for semantic caching
2929
* The API Management instance must be configured to use managed identity authentication to the Azure OpenAI APIs. For more information, see [Authenticate and authorize access to Azure OpenAI APIs using Azure API Management ](api-management-authenticate-authorize-azure-openai.md#authenticate-with-managed-identity).
30-
* An [Azure Cache for Redis Enterprise](../azure-cache-for-redis/quickstart-create-redis-enterprise.md) or [Azure Managed Redis](../azure-cache-for-redis/quickstart-create-managed-redis.md) instance. The **RediSearch** module must be enabled on the Redis cache.
30+
* An [Azure Cache for Redis Enterprise](../azure-cache-for-redis/quickstart-create-redis-enterprise.md) or [Azure Managed Redis](../redis/quickstart-create-managed-redis.md) instance. The **RediSearch** module must be enabled on the Redis cache.
3131
> [!NOTE]
32-
> You can only enable the **RediSearch** module when creating a new Azure Redis Enterprise or Azure Managed Redis cache. You can't add a module to an existing cache. [Learn more](../azure-cache-for-redis/cache-redis-modules.md)
32+
> You can only enable the **RediSearch** module when creating a new Azure Redis Enterprise or Azure Managed Redis cache. You can't add a module to an existing cache. [Learn more](../redis/redis-modules.md)
3333
* External cache configured in the Azure API Management instance. For steps, see [Use an external Redis-compatible cache in Azure API Management](api-management-howto-cache-external.md).
3434

3535

articles/api-management/azure-openai-semantic-cache-lookup-policy.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ Use the `azure-openai-semantic-cache-lookup` policy to perform cache lookup of r
4545

4646
| Attribute | Description | Required | Default |
4747
| ----------------- | ------------------------------------------------------ | -------- | ------- |
48-
| score-threshold | Similarity score threshold used to determine whether to return a cached response to a prompt. Value is a decimal between 0.0 and 1.0. [Learn more](../azure-cache-for-redis/cache-tutorial-semantic-cache.md#change-the-similarity-threshold). | Yes | N/A |
48+
| score-threshold | Similarity score threshold used to determine whether to return a cached response to a prompt. Value is a decimal between 0.0 and 1.0. [Learn more](../redis/tutorial-semantic-cache.md#change-the-similarity-threshold). | Yes | N/A |
4949
| embeddings-backend-id | [Backend](backends.md) ID for OpenAI embeddings API call. | Yes | N/A |
5050
| embeddings-backend-auth | Authentication used for Azure OpenAI embeddings API backend. | Yes. Must be set to `system-assigned`. | N/A |
5151
| ignore-system-messages | Boolean. If set to `true`, removes system messages from a GPT chat completion prompt before assessing cache similarity. | No | false |

0 commit comments

Comments
 (0)