Remove Azure Functions from Container Architecture - Simplify to Express.js

Resolved 💬 2 comments Opened Aug 23, 2025 by kabzadev Closed Aug 25, 2025

Problem Statement

The current container architecture is fundamentally flawed - we're running Azure Functions inside containers, which creates unnecessary complexity and deployment failures.

Current Issues

  • ❌ Azure Functions runtime inside containers causes connection resets
  • ❌ Complex port mapping conflicts (80 vs 7071)
  • ❌ Azure Functions expects specific runtime environment not available in container instances
  • ❌ Overcomplicated deployment pipeline with multiple failure points
  • ❌ Container shows "Running" but HTTP endpoints don't respond

Current Architecture (Broken)

Container Instance
├── Azure Functions Runtime (func start)
├── Port 7071/80 conflicts
├── Azure Functions expecting App Service environment
└── PowerShell execution through Azure Functions

Proposed Solution

Replace Azure Functions with simple Express.js HTTP server that directly executes PowerShell.

New Architecture (Simple)

Single Container
├── Express.js HTTP Server (port 8080)
│   ├── /api/health
│   ├── /api/teams/policies
│   ├── /api/teams/policies/sync
│   └── /api/teams/connection/test
├── PowerShell Service Layer
│   ├── Direct pwsh execution via Node.js spawn()
│   ├── Teams Module 7.3.0
│   └── Dual-token authentication
└── Infrastructure
    ├── Node.js 18
    ├── PowerShell 7.x
    └── MicrosoftTeams module

Implementation Tasks

Phase 1: Express.js Server

  • [ ] Create Express.js application structure
  • [ ] Implement REST endpoints for Teams operations
  • [ ] Direct PowerShell execution via child_process.spawn()
  • [ ] Health check endpoint
  • [ ] CORS configuration

Phase 2: PowerShell Integration

  • [ ] Migrate existing PowerShell dual-token authentication logic
  • [ ] Direct PowerShell script execution (no Azure Functions wrapper)
  • [ ] Error handling and logging
  • [ ] Teams policy CRUD operations

Phase 3: Container & Deployment

  • [ ] Create simplified Dockerfile (Node.js + PowerShell only)
  • [ ] Remove all Azure Functions dependencies
  • [ ] Single port exposure (8080)
  • [ ] Environment variable configuration
  • [ ] Azure Container Instance deployment

Phase 4: Testing & Verification

  • [ ] Local container testing
  • [ ] Teams PowerShell authentication verification
  • [ ] Policy retrieval testing (expect 15 policies from Contoso tenant)
  • [ ] End-to-end container deployment testing

Expected Benefits

Simplified Architecture: Single purpose container with clear responsibilities
Reliable Deployment: No Azure Functions runtime complexity
Direct PowerShell: No wrapper layers, direct execution
Better Debugging: Clear logs and error messages
Performance: Reduced overhead, faster startup
Maintainability: Standard Express.js patterns

Files to Modify

  • Dockerfile - Remove Azure Functions, add Express.js
  • package.json - Replace Azure Functions deps with Express
  • src/server.ts - New Express.js entry point
  • src/routes/ - REST endpoint definitions
  • src/services/PowerShellService.ts - Direct PowerShell execution
  • Remove host.json, local.settings.json Azure Functions configs

Priority: High

This is blocking Teams PowerShell functionality. Current container deployments fail to respond to HTTP requests due to Azure Functions runtime issues.

Environment Context

  • Service Principal: 0b6c6933-5be2-4022-9cd9-4ceba3d32992
  • Tenant: 3a127287-9a43-48e2-8b73-23b84562a9f9
  • Dual-token Auth: Implementation ready ✅
  • Teams Module: 7.3.0 with GFC support ✅

The authentication and PowerShell logic are working - we just need proper HTTP server architecture.

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗