Task 03 - Troubleshoot at runtime with AI assistance

Introduction

You can troubleshoot your GitHub Actions workflow directly, or use AI to assist with diagnosing issues. This exercise will show you how to troubleshoot with AI.

Description

In this task you will learn how to troubleshoot common issues with your GitHub Actions workflow using AI.

Success Criteria

  • You will successfully fix any issues with your application after deployment
  • You will learn important tips for troubleshooting your application using AI

Key Tasks

When your workflow completes successfully but the application fails to respond properly, use this systematic approach to diagnose and resolve issues with GitHub Copilot’s assistance.

01: Identify the Problem

Test your application and gather initial information about the error to provide context for troubleshooting.

Expand this section for detailed steps
  1. Test Your Application
    • Visit your app URL: https://<your-app-name>.azurewebsites.net
    • Note the specific error you encounter:
      • 500 Internal Server Error: Application crash or configuration issue
      • 502 Bad Gateway: Port mismatch or container startup failure
      • 504 Gateway Timeout: Application taking too long to respond
      • Application Error: Generic Azure App Service error page
  2. Gather Initial Information
    • Record the exact error message or status code
    • Note the timestamp when the error occurred
    • Check if the error is consistent or intermittent

02: Engage Copilot for Diagnosis

Use GitHub Copilot Chat to provide specific details about the issue and request diagnostic assistance.

Expand this section for detailed steps
  1. In Copilot Chat, provide specific details about the issue using a prompt such as:

     My Azure App Service is not loading when I visit it at https://<your-app-name>.azurewebsites.net
    
     I'm getting a [specific error: 500/502/504/Application Error] error.
    
     My deployment workflow completed successfully, but the application isn't responding correctly.
    
     Please help me investigate this issue by:
     1. Checking the App Service logs
     2. Verifying the container configuration
     3. Identifying potential causes
     4. Providing specific fixes
    
     My resource details:
     - App Service: <your-app-name>
     - Resource Group: <your-resource-group>
     - Container Registry: <your-acr-name>
    

03: Follow Copilot’s Diagnostic Steps

Follow the diagnostic steps that Copilot recommends, which typically include log analysis, configuration verification, and container status checks.

Expand this section for detailed steps
  1. Log Analysis
    # Check App Service logs
    az webapp log tail --name <your-app-name> --resource-group <your-resource-group>
    
    # Check deployment logs
    az webapp log deployment list --name <your-app-name> --resource-group <your-resource-group>
    
  2. Configuration Verification
    # Check app settings
    az webapp config appsettings list --name <your-app-name> --resource-group <your-resource-group>
    
    # Check container settings
    az webapp config show --name <your-app-name> --resource-group <your-resource-group>
    
  3. Container Status
    # Check if container is running
    az webapp show --name <your-app-name> --resource-group <your-resource-group> --query "state"
    

Apply the fixes that Copilot recommends, which may include port configuration, authentication, or application configuration changes.

Expand this section for common fix categories

Common fixes Copilot may suggest include:

Port Configuration Issues:

  • Update WEBSITES_PORT setting
  • Modify ASPNETCORE_URLS configuration
  • Adjust Dockerfile EXPOSE directive

Authentication Issues:

  • Enable Managed Identity for ACR access
  • Update container registry authentication settings
  • Verify service principal permissions

Application Configuration:

  • Add missing environment variables
  • Update Application Insights connection string
  • Configure proper startup commands

05: Test and Iterate

After applying each fix, redeploy if needed, commit changes, monitor the workflow, test the application, and iterate until the issue is resolved.

Expand this section for detailed steps
  1. Redeploy Infrastructure (if needed)
    azd up
    
  2. Commit and Push Changes
    git add .
    git commit -m "Fix: [description of the fix applied]"
    git push origin dev
    
  3. Wait for Workflow Completion
    • Monitor the GitHub Actions workflow
    • Ensure all steps complete successfully
  4. Test the Application
    • Restart the App Service if needed:
      az webapp restart --name <your-app-name> --resource-group <your-resource-group>
      
    • Visit the application URL again
    • Check for improvements or new error messages
  5. Continue Iteration
    • If issues persist, return to Copilot with updated information
    • Provide any new error messages or log entries
    • Continue the diagnostic process

06: Example Troubleshooting Conversation

Review an example conversation flow to understand how to interact with Copilot during troubleshooting.

Expand this section to view an example conversation

Here’s an example of how the conversation with Copilot might progress:

Initial Problem:

My app shows "Application Error" when I visit https://app-zavastorefront-dev.azurewebsites.net

Copilot Response: “Let me help you diagnose this. First, let’s check the logs…”

Follow-up After Log Review:

I ran the log command and see this error:
"Microsoft.AspNetCore.Server.Kestrel[0] Unable to bind to http://localhost:5000"

What does this mean and how do I fix it?

Copilot’s Fix: “This is a port binding issue. Your app is trying to bind to localhost:5000, but Azure App Service expects it to bind to port 80…”

07: Benefits of This AI-Assisted Approach

Understand the benefits of using AI-assisted troubleshooting, including real-world DevOps practices, efficient problem solving, and skill development.

Expand this section for detailed benefits

Real-World DevOps Practice:

  • Mirrors how experienced DevOps engineers troubleshoot issues
  • Combines automated diagnostics with human insight
  • Provides learning opportunities through explanation

Efficient Problem Solving:

  • Faster than manual documentation searches
  • Context-aware suggestions based on your specific configuration
  • Iterative refinement until resolution

Skill Development:

  • Learn Azure troubleshooting techniques
  • Understand common container deployment issues
  • Build confidence in cloud infrastructure debugging

NOTE

  • Non-Deterministic Results: Your final configuration may differ from others based on the specific issues encountered
  • Learning Process: Each troubleshooting session teaches you more about Azure App Service and containerized deployments
  • Documentation: Consider documenting the solutions for future reference
  • Patience Required: Some issues may require multiple iterations to resolve completely

NOTE Keep detailed notes of the issues encountered and their solutions. This creates a valuable troubleshooting knowledge base for your team.

Summary

You’ve completed this task. You have successfully fixed any issues with your application after deployment and learned important tips for troubleshooting your application using AI.