Skip to content

Commit 534bcda

Browse files
Merge pull request #194605 from HeidiSteen/heidist-ngrok
[azure search] Debug custom skill locally with ngrok
2 parents 240efc7 + 216b3fe commit 534bcda

File tree

2 files changed

+37
-2
lines changed

2 files changed

+37
-2
lines changed

articles/search/cognitive-search-how-to-debug-skillset.md

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ author: HeidiSteen
88
ms.author: heidist
99
ms.service: cognitive-search
1010
ms.topic: how-to
11-
ms.date: 12/31/2021
11+
ms.date: 04/10/2022
1212
---
1313

1414
# Debug an Azure Cognitive Search skillset in Azure portal
1515

16-
Start a debug session to identify and resolve errors, validate changes, and push changes to a published skillset in your Azure Cognitive Search service.
16+
Start a portal-based debug session to identify and resolve errors, validate changes, and push changes to a published skillset in your Azure Cognitive Search service.
1717

1818
A debug session is a cached indexer and skillset execution, scoped to a single document, that you can use to edit and test your changes interactively. If you're unfamiliar with how a debug session works, see [Debug sessions in Azure Cognitive Search](cognitive-search-debug-session.md). To practice a debug workflow with a sample document, see [Tutorial: Debug sessions](cognitive-search-tutorial-debug-sessions.md).
1919

@@ -129,6 +129,41 @@ If skills produce output but the search index is empty, check the field mappings
129129

130130
:::image type="content" source="media/cognitive-search-debug/output-field-mappings.png" alt-text="Screenshot of the Output Field Mappings node and details." border="true":::
131131

132+
## Debug a custom skill locally
133+
134+
Custom skills can be more challenging to debug because the code runs externally. This section describes how to locally debug your Custom Web API skill, debug session, Visual Studio Code and [ngrok](https://ngrok.com/docs). This technique works with custom skills that execute in [Azure Functions](../azure-functions/functions-overview.md) or any other Web Framework that runs locally (for example, [FastAPI](https://fastapi.tiangolo.com/)).
135+
136+
### Run ngrok
137+
138+
[**ngrok**](https://ngrok.com/docs) is a cross-platform application that can create a tunneling or forwarding URL, so that internet requests reach your local machine. Use ngrok to forward requests from an enrichment pipeline in your search service to your machine to allow local debugging.
139+
140+
1. Install ngrok.
141+
142+
1. Open a terminal and go to the folder with the ngrok executable.
143+
144+
1. Run ngrok with the following command to create a new tunnel:
145+
146+
```console
147+
ngrok http 7071
148+
```
149+
150+
> [!NOTE]
151+
> By default, Azure Functions are exposed on 7071. Other tools and configurations might require that you provide a different port.
152+
153+
1. When ngrok starts, copy and save the public forwarding URL for the next step. The forwarding URL is randomly generated.
154+
155+
:::image type="content" source="media/cognitive-search-debug/ngrok.png" alt-text="Screenshot of ngrok terminal." border="false":::
156+
157+
### Configure in Azure portal
158+
159+
Within the debug session, modify your Custom Web API Skill URI to call the ngrok forwarding URL. Ensure that you append "/api/FunctionName" when using Azure Function for executing the skillset code.
160+
161+
You can edit the skill definition in the portal.
162+
163+
### Test
164+
165+
At this point, new requests from your debug session should now be sent to your local Azure Function. You can use breakpoints in your Visual Studio code to debug your code or run step by step.
166+
132167
## Next steps
133168

134169
Now that you understand the layout and capabilities of the Debug Sessions visual editor, try the tutorial for a hands-on experience.
39.2 KB
Loading

0 commit comments

Comments
 (0)