Skip to content

fix: deployment errors for the AI Agent GOV backend and enable a successful deploy to Azure Web App via GitHub Actions. #334

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 160 commits into from

Conversation

somc-ai
Copy link

@somc-ai somc-ai commented Jul 17, 2025

Purpose

Goal:
Resolve deployment failure for the AI Agent GOV backend, caused by errors during ZIP deployment to Azure Web App using Oryx build pipeline.

Errors Observed During Deployment:

Error: Failed to deploy web package to App Service.
Error: Deployment Failed, Package deployment using ZIP Deploy failed. Refer logs for more details.

Additional context from Azure log:

Updating submodules.
Preparing deployment for commit id 'f294b18e-1'.
PreDeployment: context.CleanOutputPath False
PreDeployment: context.OutputPath /home/site/wwwroot
Repository path is /tmp/zipdeploy/extracted
Running oryx build...
Command: oryx build /tmp/zipdeploy/extracted -o /home/site/wwwroot --platform python --platform-version 3.11 -p virtualenv_name=antenv --log-file /tmp/build-debug.log  -i /tmp/8ddc515382de79f --compress-destination-dir | tee /tmp/oryx-build.log
Operation performed by Microsoft Oryx, https://github.com/Microsoft/Oryx

Analysis

These errors suggest that the Oryx build process failed during deployment. This typically happens due to one or more of the following reasons:

  • ❌ No valid Python entry point found (e.g. app.py, main.py, or FastAPI app instance)
  • requirements.txt contains invalid, broken, or unsupported packages (e.g. Git-based installs, local paths)
  • ❌ Python source code is not located in the root or expected subfolder (/tmp/zipdeploy/extracted structure mismatch)
  • ❌ Multiple conflicting app_kernel.py files (one in root, one in /backend/) may confuse Oryx during scanning
  • ❌ Missing or misnamed startup file (Azure looks for application.py, main.py, or auto-detects a FastAPI app)

Required Fixes

  1. ENTRY POINT

    • Ensure the correct main.py or app.py exists at the root of the deployment folder (typically copied to /tmp/zipdeploy/extracted)
    • It must contain a FastAPI app named app (e.g. app = FastAPI())
  2. REQUIREMENTS.TXT

    • No git+... or local imports
    • Only pip-installable packages
    • Test locally: pip install -r backend/requirements.txt must work clean
  3. REMOVE DUPLICATES

    • Delete the duplicate app_kernel.py in the root directory
    • Ensure only the correct file in backend/ is used
  4. UPDATE WORKFLOW / ZIP PATH

    • Ensure the GitHub Action or deployment ZIP contains a clean structure like:

      /main.py
      /requirements.txt
      /backend/app_kernel.py
      

Does this introduce a breaking change?

  • Yes
  • No

How to Test

# Local test
cd backend/
pip install -r requirements.txt
python ../main.py
  • Run: curl http://localhost:8000/docs
  • If using uvicorn, ensure the startup command is:
uvicorn main:app --host 0.0.0.0 --port 8000

What to Check

  • main.py exists at root, contains app = FastAPI()

  • requirements.txt is valid and clean

  • No duplicate kernel files

  • /tmp/zipdeploy/extracted matches what Azure expects:

    • Root-level app entry
    • All dependencies resolved
    • Python version matches (3.11)

Other Information

  • Deployment pipeline: .github/workflows/main_aiagentsgov-backend.yml
  • Build system: Azure App Service with Oryx
  • Platform: Python 3.11

Check if the files like requirements.txt, and other are perfect enough for deployment

@Copilot Copilot AI review requested due to automatic review settings July 25, 2025 18:47
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes critical deployment errors for the AI Agent GOV backend to enable successful deployment to Azure Web App via GitHub Actions. The changes address build failures, authentication issues, and missing entry points that were preventing the Oryx build pipeline from working correctly.

Key changes include:

  • Restructured backend application with proper entry point (main.py) at repository root
  • Cleaned up requirements.txt to remove problematic git-based dependencies
  • Implemented fallback authentication strategies for Azure services
  • Added comprehensive deployment configurations and Docker optimizations

Reviewed Changes

Copilot reviewed 52 out of 56 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
main.py New root-level entry point for Azure Web App deployment
zeeland-autogen-backend/ New simplified backend structure with clean requirements
src/backend/app_kernel.py Updated with mock responses and improved error handling
src/backend/requirements.txt Simplified dependencies without git references
web.config Azure Web App configuration for Python deployment
.github/workflows/ Multiple deployment workflows for different Azure services
Files not reviewed (1)
  • src/frontend/package-lock.json: Language not supported
Comments suppressed due to low confidence (2)

src/frontend/src/App.tsx:6

  • There are conflicting import statements - React is imported twice (line 1 and line 6) with different syntax. This will cause a compilation error.
  const [selectedAgents, setSelectedAgents] = useState([]);

@@ -47,17 +48,49 @@ def __init__(
system_message = system_message or self.default_system_message(agent_name)

# Call AzureAIAgent constructor with required client and definition
def __init__(
Copy link
Preview

Copilot AI Jul 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are two init method definitions in the BaseAgent class (lines 22 and 51). This creates a syntax error as Python classes cannot have duplicate method definitions. The second definition will override the first, making the code unreachable.

Copilot uses AI. Check for mistakes.

Comment on lines +6 to +15
import React, { useState } from 'react';
import './App.css';

function App() {
const [selectedAgents, setSelectedAgents] = useState([]);
const [scenario, setScenario] = useState('');
const [isAnalyzing, setIsAnalyzing] = useState(false);
const [analysis, setAnalysis] = useState(null);


Copy link
Preview

Copilot AI Jul 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are duplicate import statements for React and duplicate function declarations (App on line 9 and SoMCDashboard on line 16). This creates syntax errors and unreachable code.

Suggested change
import React, { useState } from 'react';
import './App.css';
function App() {
const [selectedAgents, setSelectedAgents] = useState([]);
const [scenario, setScenario] = useState('');
const [isAnalyzing, setIsAnalyzing] = useState(false);
const [analysis, setAnalysis] = useState(null);
function App() {
return (
<div>
<h1>Welcome to the App</h1>
<SoMCDashboard />
</div>
);
}

Copilot uses AI. Check for mistakes.

from semantic_kernel.functions import KernelFunction

# Default formatting instructions used across agents
DEFAULT_FORMATTING_INSTRUCTIONS = "Instructions: returning the output of this function call verbatim to the user in markdown. Then write AGENT SUMMARY: and then include a summary of what you did."


class BaseAgent(AzureAIAgent):
class BaseAgent(ChatCompletionAgent):
Copy link
Preview

Copilot AI Jul 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The class inheritance has been changed from AzureAIAgent to ChatCompletionAgent, but the constructor still references the old parent class methods and parameters. This will likely cause runtime errors when the BaseAgent is instantiated.

Copilot uses AI. Check for mistakes.

Comment on lines +7 to +9
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
Copy link
Preview

Copilot AI Jul 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CORS middleware is configured with 'allow_origins=["*"]' which allows requests from any origin. This is a security risk in production and should be restricted to specific trusted domains.

Suggested change
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
import os
allowed_origins = os.getenv("ALLOWED_ORIGINS", "").split(",") if os.getenv("ALLOWED_ORIGINS") else ["http://localhost", "https://example.com"]
app.add_middleware(
CORSMiddleware,
allow_origins=allowed_origins,

Copilot uses AI. Check for mistakes.

<add name="PythonHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified"/>
</handlers>
<httpPlatform processPath="python"
arguments="-m uvicorn main:app --host 0.0.0.0 --port %HTTP_PLATFORM_PORT%"
Copy link
Preview

Copilot AI Jul 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The web.config references 'main:app' but based on the file structure, this should likely be 'app_kernel:app' or the path needs to be adjusted to match the actual application entry point.

Suggested change
arguments="-m uvicorn main:app --host 0.0.0.0 --port %HTTP_PLATFORM_PORT%"
arguments="-m uvicorn app_kernel:app --host 0.0.0.0 --port %HTTP_PLATFORM_PORT%"

Copilot uses AI. Check for mistakes.

devin-ai-integration bot and others added 22 commits July 25, 2025 19:08
…tion and restart

- Add proper escaping for environment variables in az containerapp update
- Add verification step to confirm environment variables are set
- Force Container App restart to ensure environment variables are loaded
- This should resolve persistent DefaultAzureCredential authentication failures

Co-Authored-By: [email protected] <[email protected]>
…ps-env-vars-comprehensive

fix: comprehensive Container Apps environment variables with verifica…
…b0-36e04764573e

[WIP] Voeg POST /plan endpoint toe aan backend (FastAPI)
…56-2fedd223fb13

[WIP] Er is een fout in mijn frontend die een POST naar `/plan` doet, maar dit backend endpoint bestaat niet. Maak een werkend FastAPI endpoint aan in de backend die `session_id` en `description` ontvangt en dummy JSON terugstuurt. Commit dit naar een nieuwe ...
- Add npm build process to create frontend build directory
- Update frontend_server.py with fallback backend URL configuration
- Update App.tsx with fallback mechanism for localhost URLs
- Fix 'Cannot GET /' error by ensuring index.html is available
- Improve CORS and static file serving configuration
- Add proper error handling and debugging capabilities
- Resolve merge conflicts in App.tsx and Dockerfile.azure
- Keep improved error handling and fallback mechanisms
- Maintain backend URL configuration improvements
- Include build process fixes for frontend deployment
- Add proper MIME types for JavaScript and CSS assets
- Improve CORS configuration for Azure environment
- Add health check endpoint for container monitoring
- Add debug endpoint to troubleshoot build contents
- Enhance static file serving with proper content types
- Add explicit routes for all static assets
- Fix asset loading issues in production environment
- Add comprehensive test page at /test endpoint
- Test config endpoint, backend connection, and API functionality
- Provide visual debugging interface for Azure deployment issues
- Auto-run config test on page load
- Test all critical API endpoints with detailed output
- Fixed Dockerfile.azure merge conflicts
- Backend ready with 7 AI specialisten (HR, Marketing, Product, Procurement, Tech Support, Generic, Planner)
- Working /api/agent-tools endpoint for frontend integration
- Fallback system ensures Azure compatibility
…ocumentation

- Add /input_task endpoint for frontend compatibility alongside /api/input_task
- Add /specialists endpoint alongside /api/agent-tools
- Enhanced root endpoint with full API documentation
- Cleaned up requirements.txt with proper OpenAI version
- Ensures backward compatibility while maintaining professional API structure
- Backend now accepts selected_agents parameter in InputTask model
- Frontend sends selected agent expertise list to backend
- Backend filters responses to only include selected specialists
- Eliminates unwanted responses from unselected agents
- Maintains professional AI analysis quality for chosen experts only
- Improved AI prompts to focus on scenario-specific analysis instead of generic templates
- Increased max_tokens from 500 to 800 for more detailed responses
- Enhanced user prompt to explicitly request contextual analysis
- Improved fallback responses to be context-aware instead of generic
- Focus on concrete, actionable insights specific to user scenarios
- Eliminates template-style responses for truly strategic analysis
- Enhanced logging to track OpenAI API configuration and calls
- Added detailed exception logging to identify AI response failures
- Will help diagnose why fallback responses are being used
- Temporary debug version to resolve genereric response issue
@Roopan-Microsoft
Copy link
Collaborator

Roopan-Microsoft commented Jul 29, 2025

Hi @somc-ai - Just checking—are you customizing the accelerator for your own use, or suggesting changes to the original repo? We noticed several UI changes. If this PR isn’t intended for the main repo, please go ahead and close it.

@Roopan-Microsoft
Copy link
Collaborator

Closing this Pull request as its not relevant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants