Skip to content

Commit 769bbfc

Browse files
committed
Added self-guided lab content
1 parent b1eeb06 commit 769bbfc

File tree

5 files changed

+1808
-11
lines changed

5 files changed

+1808
-11
lines changed

README.md

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,20 +41,22 @@ The project ships with reproducible **azd** infrastructure, so `azd up` will sta
4141
> This repository is intended for learning and demonstration purposes. **Do not** deploy it to production without a thorough security review. At a minimum you should:
4242
>
4343
> * Swap connection strings for **Managed Identity** + **Azure Key Vault**
44-
> * Restrict network access to Azure services via Private Endpoints or service‑tags
45-
> * Enable GitHub secret‑scanning and CI security tools
44+
* Restrict network access to Azure services via Private Endpoints or service‑tags
45+
* Enable GitHub secret‑scanning and CI security tools
4646

47-
[Features](#features) • [Architecture](#architecture-diagram) • [Getting Started](#getting-started) • [Guidance](#guidance)
47+
[Features](#features)[Architecture](#architecture)[Lab Tutorial](#lab-tutorial)[Getting Started](#getting-started)[Guidance](#guidance)
4848

4949
---
5050

51-
## Recent Updates
51+
## Architecture
5252

53-
* **Durable Task Scheduler (DTS) integration** for cloud orchestration and monitoring
54-
* **DTS dashboard scripts**: Quickly generate monitoring URLs for Azure deployments (`scripts/get-dts-dashboard-url.sh` and `.ps1`)
55-
* **Multi-agent orchestration**: Coordinate DeepWiki and CodeStyle agents with Durable Functions
56-
* **Enhanced monitoring**: View orchestration state in local DTS emulator or Azure DTS dashboard
53+
Snippy demonstrates a modern serverless AI application architecture where Azure Functions serve as both traditional APIs and MCP-compatible tools that AI assistants can discover and use:
5754

55+
![Snippy Architecture](images/Snippy-Architecture-V2-L.png)
56+
57+
The system uses **Durable Task Scheduler** to orchestrate multi-agent workflows, **Cosmos DB with vector indexing** for semantic code search, and **Azure OpenAI** for embeddings and LLM capabilities. The same codebase runs locally with Docker-based emulators or deploys to Azure with `azd up`.
58+
59+
---
5860

5961
## Features
6062

@@ -78,13 +80,31 @@ The project ships with reproducible **azd** infrastructure, so `azd up` will sta
7880

7981
---
8082

81-
### Architecture Diagram
83+
## Lab Tutorial
8284

83-
![Snippy Architecture](images/Snippy-Architecture-V2-L.png)
85+
New to Snippy? Start with our comprehensive **hands-on lab tutorial** that guides you through building the entire application from scratch:
86+
87+
📚 **[Snippy Tutorial: Building an AI-Enhanced Code Snippet Manager](lab/TUTORIAL.md)**
88+
89+
The tutorial covers:
90+
91+
* **Step-by-step implementation** – Build the complete application with detailed explanations
92+
* **Code review exercises** – Understand MCP tools, durable agents, and vector search patterns
93+
* **Local development** – Set up and test with Docker-based emulators
94+
* **Azure deployment** – Provision and deploy to production with azd
95+
* **Multi-agent orchestration** – Monitor complex workflows with DTS dashboard
96+
* **End-to-end testing** – Test with REST Client, GitHub Copilot, and MCP tools
97+
98+
**Additional Resources:**
99+
100+
* [Quick Reference](lab/QUICK_REFERENCE.md) – Essential commands and common tasks
101+
* [Troubleshooting Guide](lab/TROUBLESHOOTING.md) – Solutions to common issues
102+
103+
Whether you're new to Azure Functions, MCP tools, or AI agent development, the lab provides a structured learning path with hands-on experience.
84104

85105
---
86106

87-
## Getting Started
107+
## Getting Started
88108

89109
You can run Snippy in **GitHub Codespaces**, **VS Code Dev Containers**, or your **local environment**. The fastest path is Codespaces.
90110

lab/QUICK_REFERENCE.md

Lines changed: 267 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,267 @@
1+
# Quick Reference
2+
3+
Essential commands and tips for working with Snippy.
4+
5+
## Setup Commands
6+
7+
### Initial Setup
8+
9+
```bash
10+
# Clone the repository
11+
git clone https://github.com/Azure-Samples/snippy.git
12+
cd snippy
13+
14+
# Login to Azure
15+
az login
16+
17+
# Login to Azure Developer CLI
18+
azd auth login
19+
```
20+
21+
### Create Environment
22+
23+
```bash
24+
# Create a unique azd environment
25+
azd env new snippymcplab-<unique-suffix> --subscription <your-subscription-id>
26+
27+
# Set name suffix
28+
azd env set NAME_SUFFIX <unique-suffix>
29+
30+
# Provision Azure resources (takes 5-10 minutes)
31+
azd provision
32+
```
33+
34+
### Python Setup
35+
36+
```bash
37+
# Navigate to src directory
38+
cd src
39+
40+
# Create virtual environment with uv
41+
uv venv .venv
42+
43+
# Activate virtual environment
44+
source .venv/bin/activate # macOS/Linux
45+
.venv\Scripts\Activate.ps1 # Windows PowerShell
46+
.venv\Scripts\activate.bat # Windows CMD
47+
48+
# Install dependencies
49+
uv pip install -r requirements.txt
50+
```
51+
52+
### Start Local Development
53+
54+
```bash
55+
# Start Docker services (from root directory)
56+
docker compose up -d
57+
58+
# Start Functions host (from src directory)
59+
cd src
60+
func start
61+
```
62+
63+
## Common Tasks
64+
65+
### Regenerate Settings
66+
67+
```bash
68+
# From repository root
69+
./scripts/generate-settings.sh # macOS/Linux
70+
.\scripts\generate-settings.ps1 # Windows
71+
```
72+
73+
### Deploy to Azure
74+
75+
```bash
76+
# From repository root
77+
azd deploy
78+
```
79+
80+
### Get Function App Details
81+
82+
```bash
83+
# Get function app name
84+
azd env get-value AZURE_FUNCTION_NAME
85+
86+
# Get resource group
87+
azd env get-value AZURE_RESOURCE_GROUP
88+
89+
# Get MCP system key
90+
az functionapp keys list \
91+
-n $(azd env get-value AZURE_FUNCTION_NAME) \
92+
-g $(azd env get-value AZURE_RESOURCE_GROUP) \
93+
--query "systemKeys.mcp_extension" \
94+
--output tsv
95+
```
96+
97+
### View Logs
98+
99+
```bash
100+
# Local function logs
101+
# (visible in terminal where `func start` is running)
102+
103+
# Docker container logs
104+
docker compose logs
105+
106+
# Azure function logs
107+
func azure functionapp logstream <function-app-name>
108+
```
109+
110+
## MCP Configuration
111+
112+
### Local MCP Server
113+
114+
In `.vscode/mcp.json`:
115+
116+
```json
117+
{
118+
"mcpServers": {
119+
"local-snippy": {
120+
"type": "sse",
121+
"url": "http://localhost:7071/runtime/webhooks/mcp"
122+
}
123+
}
124+
}
125+
```
126+
127+
### Remote MCP Server
128+
129+
After deployment, update `.vscode/mcp.json`:
130+
131+
```json
132+
{
133+
"mcpServers": {
134+
"remote-snippy": {
135+
"type": "sse",
136+
"url": "https://<function-app-name>.azurewebsites.net/runtime/webhooks/mcp",
137+
"headers": {
138+
"x-functions-key": "<mcp-system-key>"
139+
}
140+
}
141+
}
142+
}
143+
```
144+
145+
## Copilot Commands
146+
147+
### Using MCP Tools
148+
149+
``` text
150+
# Save a snippet
151+
#local-snippy save this snippet as my-snippet-name
152+
153+
# Retrieve a snippet
154+
#local-snippy get the snippet named my-snippet-name
155+
156+
# Generate documentation
157+
#local-snippy generate a deep wiki for all snippets
158+
159+
# Create style guide
160+
#local-snippy create a code style guide based on saved snippets
161+
162+
# Multi-agent orchestration
163+
#local-snippy generate comprehensive documentation
164+
```
165+
166+
## Testing Endpoints
167+
168+
### Using VS Code REST Client
169+
170+
Open `src/tests/test.http` and click "Send Request" above any request.
171+
172+
### Using curl
173+
174+
```bash
175+
# Save a snippet
176+
curl -X POST http://localhost:7071/api/snippets \
177+
-H "Content-Type: application/json" \
178+
-d '{"name":"test","code":"print(\"hello\")","projectId":"default"}'
179+
180+
# Get a snippet
181+
curl http://localhost:7071/api/snippets/test
182+
```
183+
184+
## Troubleshooting Quick Fixes
185+
186+
### Port Already in Use
187+
188+
```bash
189+
# Kill process on port 7071
190+
lsof -ti:7071 | xargs kill -9 # macOS/Linux
191+
Get-Process -Id (Get-NetTCPConnection -LocalPort 7071).OwningProcess | Stop-Process # Windows
192+
```
193+
194+
### Docker Not Running
195+
196+
```bash
197+
# Check Docker status
198+
docker ps
199+
200+
# Restart Docker Desktop app if needed
201+
```
202+
203+
### Virtual Environment Issues
204+
205+
```bash
206+
# Deactivate and recreate
207+
deactivate
208+
rm -rf .venv
209+
uv venv .venv
210+
source .venv/bin/activate # or Windows equivalent
211+
uv pip install -r requirements.txt
212+
```
213+
214+
### MCP Not Connecting
215+
216+
1. Command Palette → `MCP Tools: Reset Cached Tools`
217+
2. Restart VS Code
218+
3. Check `.vscode/mcp.json` configuration
219+
4. View logs: Command Palette → `MCP: List Servers` → Show Output
220+
221+
## Cleanup
222+
223+
### Full Cleanup
224+
225+
```bash
226+
# Delete all Azure resources
227+
azd down --purge --force
228+
229+
# Stop Docker containers
230+
docker compose down -v
231+
232+
# Remove local config
233+
rm -rf .azure
234+
```
235+
236+
### Verify Cleanup
237+
238+
```bash
239+
# Check resource group is deleted
240+
az group list --output table
241+
242+
# Check Docker containers stopped
243+
docker ps
244+
```
245+
246+
## Useful Links
247+
248+
- **Azure Portal**: https://portal.azure.com
249+
- **Microsoft Foundry**: https://ai.azure.com
250+
- **MCP Inspector**: `npx @modelcontextprotocol/inspector`
251+
- **DTS Dashboard** (local): http://localhost:8082
252+
- **Azurite Blob Storage** (local): http://127.0.0.1:10000
253+
254+
## File Locations
255+
256+
- **Function code**: `src/function_app.py`
257+
- **Agent code**: `src/durable_agents.py`
258+
- **Tools**: `src/tools/vector_search.py`
259+
- **Settings**: `src/local.settings.json`
260+
- **MCP config**: `.vscode/mcp.json`
261+
- **Docker config**: `docker-compose.yml`
262+
- **Infrastructure**: `infra/main.bicep`
263+
264+
## Next Steps
265+
266+
1. **Complete the tutorial**: See [TUTORIAL.md](./TUTORIAL.md)
267+
2. **Having issues?**: Check [TROUBLESHOOTING.md](./TROUBLESHOOTING.md)

0 commit comments

Comments
 (0)