← ClaudeAtlas

sse-streaminglisted

POST-based Server-Sent Events streaming for Azure Functions — HTTP streaming, chunked response parsing, reconnection
fabioc-aloha/Alex_Skill_Mall · ★ 0 · AI & Automation · score 78
Install: claude install-skill fabioc-aloha/Alex_Skill_Mall
# SSE Streaming POST-based Server-Sent Events pattern for Azure Functions. Solves the gap where native EventSource (GET-only) can't send request bodies, and Azure Static Web Apps don't proxy WebSocket to the API layer. --- ## Why POST-Based SSE | Option | SWA API Support? | POST body? | Limitation | |--------|-----------------|------------|------------| | WebSocket | No | N/A | SWA doesn't proxy WebSocket to Functions | | EventSource | Yes | GET only | Can't send context in request body | | **POST + ReadableStream** | **Yes** | **Yes** | **Recommended pattern** | --- ## Azure Functions Setup ### Enable HTTP Streaming ```json // host.json { "version": "2.0", "extensions": { "http": { "enableHttpStream": true } } } ``` ### Streaming Function Pattern ```typescript import { app, HttpRequest, HttpResponseInit, InvocationContext } from '@azure/functions'; app.http('stream-response', { methods: ['POST'], authLevel: 'anonymous', // SWA handles auth via EasyAuth route: 'stream', handler: async (req: HttpRequest, context: InvocationContext): Promise<HttpResponseInit> => { const payload = await req.json(); const stream = new ReadableStream({ async start(controller) { try { // Stream from Azure OpenAI or any async source const aiStream = await getAIStream(payload); for await (const chunk of aiStream) { const sseData = `data: ${JSON.stringify({ text: chunk, done: false })}\n\n`;