diff --git a/README.md b/README.md index eceb60b..fc6a770 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,8 @@ Last updated: 2025-12-04 > [!IMPORTANT] > Disclaimer: This repository contains a demo of `Zava AI Shopping Assistant`, an enhanced multi-agent system implementing Agent-to-Agent (A2A) protocol for e-commerce. It features a fully automated `"Zero-Touch" deployment` pipeline orchestrated by Terraform, which `provisions infrastructure, ingests data, creates specialized AI agents with delegation patterns in MSFT Foundry, and deploys the complete A2A application stack.` Please refer [TechWorkshop L300: AI Apps and Agents](https://microsoft.github.io/TechWorkshop-L300-AI-Apps-and-agents/), and if needed contact Microsoft directly: [Microsoft Sales and Support](https://support.microsoft.com/contactus?ContactUsExperienceEntryPointAssetId=S.HP.SMC-HOME) for more guidance. There are tons of free resources out there, all eager to support! +> E.g + image > [!IMPORTANT] @@ -116,6 +118,8 @@ graph TD - Deploys AI Models (`gpt-4o-mini`, `text-embedding-3-small`). - Sets up A2A protocol infrastructure including event queues and monitoring. + > E.g + image 2. **A2A Framework Deployment**: @@ -128,10 +132,14 @@ graph TD - Sets up a Python virtual environment. - Ingests `product_catalog.csv` into Cosmos DB with A2A event notifications. + > E.g + - Creates and populates an Azure AI Search index with vector embeddings through A2A coordination. + > E.g + 4. **Enhanced Agent Creation & A2A Registration**: @@ -145,7 +153,9 @@ graph TD - Configures delegation relationships between Product Manager and specialized agents. - Saves the unique Agent IDs, delegation endpoints, and A2A configuration to the `.env` file. - image + > E.g + + image 5. **Application Deployment**: - Builds the Docker container with A2A protocol support in the cloud (ACR Build). @@ -161,6 +171,8 @@ graph TD - Visit `https://.azurewebsites.net`. - You should see the Zava chat interface with A2A protocol support. + > E.g + 2. **Verify A2A Protocol Endpoints**: @@ -175,6 +187,8 @@ graph TD - Core agents: Cora, Interior Design, Inventory, Loyalty, Cart Manager - Product Management Specialist with delegation capabilities + > E.g + 4. **Test Enhanced A2A Interactions**: For example: @@ -188,7 +202,7 @@ graph TD
- Total views -

Refresh Date: 2025-12-03

+ Total views +

Refresh Date: 2025-12-04

diff --git a/TROUBLESHOOTING.md b/TROUBLESHOOTING.md index 37ee345..28557dc 100644 --- a/TROUBLESHOOTING.md +++ b/TROUBLESHOOTING.md @@ -347,7 +347,7 @@ terraform apply
- Total views -

Refresh Date: 2025-12-03

+ Total views +

Refresh Date: 2025-12-04

diff --git a/src/Dockerfile b/src/Dockerfile index 5cf437f..b4ffb04 100644 --- a/src/Dockerfile +++ b/src/Dockerfile @@ -2,9 +2,16 @@ FROM python:3.11-slim WORKDIR /app +# Set environment variables to avoid encoding issues +ENV PYTHONUNBUFFERED=1 +ENV PYTHONIOENCODING=utf-8 + # Copy requirements first for better caching COPY requirements.txt . -RUN pip install --no-cache-dir -r requirements.txt + +# Install dependencies with better error handling +RUN pip install --no-cache-dir --upgrade pip && \ + pip install --no-cache-dir -r requirements.txt # Copy application code COPY . . diff --git a/src/a2a/.env_automation b/src/a2a/.env_automation index e06904f..b16ef54 100644 --- a/src/a2a/.env_automation +++ b/src/a2a/.env_automation @@ -4,11 +4,11 @@ A2A_PORT=8001 A2A_LOG_LEVEL=INFO # Base application URL for monitoring -BASE_APP_URL=https://zava-51c07969-app.azurewebsites.net +BASE_APP_URL=https://zava-89c29415-app.azurewebsites.net # Azure monitoring integration -APPLICATION_INSIGHTS_CONNECTION_STRING=InstrumentationKey=3ecb7f2d-bf9b-4c15-973f-39e820e44b10;IngestionEndpoint=https://westus3-1.in.applicationinsights.azure.com/;LiveEndpoint=https://westus3.livediagnostics.monitor.azure.com/;ApplicationId=c47cdc80-ebeb-4b09-a7f5-4f9b6c9502dc -LOG_ANALYTICS_WORKSPACE_ID=d3733137-0fd4-48ea-ad35-e3d066ec4d0b +APPLICATION_INSIGHTS_CONNECTION_STRING=InstrumentationKey=db468090-243d-4b9c-8e5a-063f0e5f9ca6;IngestionEndpoint=https://westus3-1.in.applicationinsights.azure.com/;LiveEndpoint=https://westus3.livediagnostics.monitor.azure.com/;ApplicationId=f1a5d58e-12b6-4618-a3c9-c9ede48ab925 +LOG_ANALYTICS_WORKSPACE_ID=fcb95690-218c-4e99-a3be-a552f4cf877d # Automation features ENABLE_PROCESS_MANAGEMENT=true diff --git a/src/a2a/status_automation.ps1 b/src/a2a/status_automation.ps1 index 54430f6..9bc6422 100644 --- a/src/a2a/status_automation.ps1 +++ b/src/a2a/status_automation.ps1 @@ -11,7 +11,7 @@ if () { # Check automation endpoint try { - = Invoke-RestMethod -Uri "https://zava-51c07969-app.azurewebsites.net/a2a/automation/status" -TimeoutSec 5 + = Invoke-RestMethod -Uri "https://zava-89c29415-app.azurewebsites.net/a2a/automation/status" -TimeoutSec 5 Write-Host "Automation Status: " } catch { Write-Host "Automation endpoint not accessible" diff --git a/src/requirements.txt b/src/requirements.txt index 0d1638d..d2a01c5 100644 --- a/src/requirements.txt +++ b/src/requirements.txt @@ -14,8 +14,5 @@ websockets==13.1 jinja2==3.1.4 python-multipart==0.0.12 orjson==3.10.7 -pydantic==2.10.4 +pydantic==2.9.2 Pillow>=10.4.0 - -# Microsoft Agent Framework for A2A Protocol (Preview) -agent-framework-azure-ai --pre diff --git a/src/requirements_minimal.txt b/src/requirements_minimal.txt deleted file mode 100644 index 071e43c..0000000 --- a/src/requirements_minimal.txt +++ /dev/null @@ -1,2 +0,0 @@ -azure-ai-projects==1.0.0b5 -azure-identity==1.19.0 diff --git a/terraform-infrastructure/README.md b/terraform-infrastructure/README.md index c1d2bac..2ebba4e 100644 --- a/terraform-infrastructure/README.md +++ b/terraform-infrastructure/README.md @@ -119,7 +119,7 @@ graph TD;
- Total views -

Refresh Date: 2025-12-03

+ Total views +

Refresh Date: 2025-12-04

diff --git a/terraform-infrastructure/main.tf b/terraform-infrastructure/main.tf index 62062ac..c7e77cc 100644 --- a/terraform-infrastructure/main.tf +++ b/terraform-infrastructure/main.tf @@ -294,6 +294,116 @@ resource "azurerm_container_registry_webhook" "webhook" { ] } +# Standalone Docker Image Build - Always runs to ensure ACR has the required image +resource "null_resource" "docker_image_build" { + # Trigger rebuild when: + # 1. Dockerfile changes + # 2. Application source code changes + # 3. Requirements.txt changes + # 4. ACR or app changes + # 5. Force rebuild on every apply (always_run ensures terraform always executes the provisioner) + triggers = { + dockerfile_hash = local.dockerfile_hash + app_source_hash = local.app_source_hash + requirements_hash = fileexists("../src/requirements.txt") ? filesha256("../src/requirements.txt") : "missing" + acr_id = azurerm_container_registry.acr.id + always_run = timestamp() # Forces provisioner to run on every apply + } + + depends_on = [ + azurerm_container_registry.acr + ] + + provisioner "local-exec" { + command = <<-EOT + Write-Host "" + Write-Host "==========================================" + Write-Host "Building & Pushing Docker Image to ACR" + Write-Host "==========================================" + Write-Host "" + + $ErrorActionPreference = "Continue" # Don't stop on warnings + cd .. + $srcPath = "src" + + Write-Host "Starting Docker build and push to ACR..." + Write-Host "Registry: ${local.registry_name}" + Write-Host "Image: zava-chat-app:latest" + Write-Host "Dockerfile: $srcPath/Dockerfile" + Write-Host "Source Path: $srcPath" + Write-Host "" + + # Set encoding for Azure CLI + $env:PYTHONIOENCODING = "utf-8" + chcp 65001 > $null + + Write-Host "Executing ACR build command..." + Write-Host "" + + try { + # Build and push image + az acr build ` + --resource-group ${azurerm_resource_group.rg.name} ` + --registry ${local.registry_name} ` + --image zava-chat-app:latest ` + --file "$srcPath\Dockerfile" ` + "$srcPath" ` + --no-logs + + if ($LASTEXITCODE -eq 0) { + Write-Host "" + Write-Host "[SUCCESS] Docker image successfully built and pushed to ACR" + Write-Host "" + Write-Host "Image details:" + Write-Host " Registry: ${local.registry_name}.azurecr.io" + Write-Host " Repository: zava-chat-app" + Write-Host " Tag: latest" + Write-Host "" + + # Wait for image to be available + Write-Host "Waiting for image to be available in registry..." + Start-Sleep -Seconds 10 + + # Verify image exists in ACR + Write-Host "Verifying image in ACR..." + $imgCheck = az acr repository show --name ${local.registry_name} --image zava-chat-app:latest --query "name" -o tsv 2>$null + + if ($LASTEXITCODE -eq 0 -and $imgCheck -eq "zava-chat-app") { + Write-Host "[VERIFIED] Image confirmed in ACR registry" + Write-Host "" + exit 0 + } else { + Write-Host "[WARNING] Image verification failed but build succeeded" + Write-Host "This may be a timing issue. Image should be available shortly." + Write-Host "" + exit 0 + } + } else { + Write-Host "" + Write-Host "[ERROR] ACR build failed with exit code: $LASTEXITCODE" + Write-Host "" + Write-Host "Troubleshooting steps:" + Write-Host " 1. Check requirements.txt for dependency conflicts" + Write-Host " 2. Verify Dockerfile paths are correct" + Write-Host " 3. Manual build command:" + Write-Host " az acr build --resource-group ${azurerm_resource_group.rg.name} --registry ${local.registry_name} --image zava-chat-app:latest --file $srcPath\Dockerfile $srcPath" + Write-Host "" + exit 1 + } + } catch { + Write-Host "" + Write-Host "[ERROR] Exception during build: $_" + Write-Host "Manual build command:" + Write-Host "az acr build --resource-group ${azurerm_resource_group.rg.name} --registry ${local.registry_name} --image zava-chat-app:latest --file $srcPath\Dockerfile $srcPath" + Write-Host "" + exit 1 + } + EOT + interpreter = ["PowerShell", "-Command"] + working_dir = path.module + } +} + resource "azurerm_service_plan" "appserviceplan" { name = local.app_service_plan resource_group_name = azurerm_resource_group.rg.name @@ -373,7 +483,8 @@ resource "azurerm_linux_web_app" "app" { depends_on = [ azurerm_container_registry.acr, - null_resource.ai_model_deployments + null_resource.ai_model_deployments, + null_resource.docker_image_build ] } @@ -1677,68 +1788,9 @@ resource "null_resource" "deploy_multi_agents" { } Write-Host "" - Write-Host "Triggering container rebuild with agent configuration..." - cd .. - $srcPath = "src" - [Console]::OutputEncoding = [System.Text.Encoding]::UTF8 - $env:PYTHONIOENCODING = "utf-8" - - Write-Host "Building container image in Azure Container Registry..." - Write-Host "This may take 2-3 minutes..." - - # Build with logs enabled to see progress - $buildSuccess = $false - try { - az acr build ` - --resource-group ${azurerm_resource_group.rg.name} ` - --registry ${local.registry_name} ` - --image zava-chat-app:latest ` - --file "$srcPath\Dockerfile" ` - "$srcPath" - - if ($LASTEXITCODE -eq 0) { - Write-Host "[SUCCESS] ACR build completed successfully" - $buildSuccess = $true - } else { - Write-Host "[ERROR] ACR build failed with exit code: $LASTEXITCODE" - } - } catch { - Write-Host "[ERROR] ACR build exception: $_" - } - - # Verify image exists - Write-Host "" - Write-Host "Verifying image in ACR..." - $imageExists = $false - for ($attempt = 1; $attempt -le 3; $attempt++) { - try { - $imgCheck = az acr repository show --name ${local.registry_name} --image zava-chat-app:latest --query "name" -o tsv 2>&1 - if ($LASTEXITCODE -eq 0 -and $imgCheck -eq "zava-chat-app") { - Write-Host "[OK] Image verified in ACR: zava-chat-app:latest" - $imageExists = $true - break - } - } catch { } - if ($attempt -lt 3) { - Write-Host "Image not found yet, waiting 10s... (attempt $attempt/3)" - Start-Sleep -Seconds 10 - } - } - - if (-not $imageExists) { - Write-Host "[CRITICAL] Image not found in ACR after build. Web App cannot start." - Write-Host "Please check ACR build logs in Azure Portal." - exit 0 # Non-blocking but logged - } - - # Web App will automatically pull image using managed identity (AcrPull role) - # No need to set ACR credentials - managed identity handles authentication - Write-Host "" - Write-Host "[INFO] Web App configured to use managed identity for ACR access" - Write-Host "[INFO] Webhook will trigger automatic deployment on image push" - + Write-Host "Docker image already built by standalone resource." Write-Host "" - Write-Host "Restarting Web App to pull new image..." + Write-Host "Restarting Web App to ensure latest configuration..." az webapp restart --resource-group ${azurerm_resource_group.rg.name} --name ${local.web_app_name} | Out-Null Write-Host "[OK] Web App restarted" Write-Host ""