Your profile

One profile for every MSDEVBUILD site. Only you can see it, and the site owner if you write in.

Lesson 8 of 28
❮Prev Next❯

Troubleshoot AKS and Container Apps: Logs, Events, Connectivity

Module 1: Containers ⏱ 10 min read Updated

Your note

My notes for this lesson

Select any text in the lesson to highlight it or add a note. Saved in this browser.

    No highlights yet. Select a sentence in the lesson, then pick a colour or add a note.

    All my bookmarks and notes

    Reading settings

    For every lesson, saved in this browser.

    Text size
    Line spacing
    Font

    With IaaS you rent the virtual machine. Microsoft looks after the building, power and hardware; you patch the operating system.

    30-second answer

    When a container app breaks, check three places. Logs show what your app said: kubectl logs (add --previous for a crashed container) on AKS, az containerapp logs show --type console on Container Apps. Events show what the platform did: kubectl describe pod and kubectl get events on AKS, --type system logs on Container Apps. Connectivity checks (Service endpoints, ports, DNS, ingress) show whether traffic can reach the app. In Log Analytics, Container Apps logs land in ContainerAppConsoleLogs_CL and ContainerAppSystemLogs_CL.

    Simulate it » No Azure account needed

    Exam objective: 1.2.4 Monitor and troubleshoot solutions on AKS and Container Apps by inspecting logs, events, and end-to-end connectivity. (Skills measured as of October 7, 2026)

    Simulations

    Feel it before you read it. No account needed, nothing leaves this page.

    Azure portal: Troubleshoot a failing container app Read the log stream, the events and the diagnostics.
    </> Embed

    Embed this simulation

    Free for trainers, teachers and bloggers. Paste this into your page:

    Loading the portal…

    You deployed v3 and the URL still serves the old version. Start at <strong>Revisions and replicas</strong>.

    👆 Click the glowing item in the portal to continue

    Read the steps as text
    1. You deployed v3 and the URL still serves the old version. Start at Revisions and replicas.
    2. v3 failed to activate. The revision status tells you that it broke; the logs tell you why.
    3. System logs come from the platform: image pulls, probes, restarts. Here the ingress target port is 8080 but the app listens on 8000.
    4. Console logs are your app’s stdout and stderr. A second problem: v3 lost the AZURE_OPENAI_ENDPOINT variable.
    5. The live stream is gone after a restart. Logs keeps the history in Log Analytics, so you can query it later.
    6. Diagnose and solve problems runs the common checks for you. Fix the port and the variable, then deploy again.

    🧪 Simulation for learning. Screens are simplified versions of the Azure portal; names, prices and IDs are examples. Nothing here touches real Azure.

    😟 THE PROBLEM

    The app is “down” and nobody knows where to start.

    😊 THE SOLUTION

    Check logs, then events, then connectivity, in that order.

    • CrashLoopBackOff✓ kubectl logs --previous
    • ImagePullBackOff✓ kubectl describe pod events
    • Can’t reach the database✓ Test DNS and ports from inside
    🛠️ Solved with: Logs, events and probes

    Start with a question

    The app says it's deployed. So why does every request time out?

    Maybe the container keeps crashing. Maybe it never started because the image name has a typo. Maybe it’s running fine but listening on the wrong port, so nothing reaches it. Each of those looks the same from the outside: no answer.

    The trick is to look in the right place. Logs tell you what the app said, events tell you what the platform did, and connectivity checks tell you whether traffic can get there.

    Explain it like I’m 10

    The technical explanation

    Read the status first

    What you seeIt usually meansLook at
    ImagePullBackOff / ErrImagePullWrong image name or tag, or no pull permissionkubectl describe pod, az aks check-acr
    CrashLoopBackOffThe app starts and exits (missing env var, bad config, exception)kubectl logs <pod> --previous
    PendingNo node has room for the pod’s requests, or a volume can’t attachEvents: FailedScheduling
    OOMKilledThe container went over its memory limitkubectl describe pod (Last State), raise the limit
    Running but 0/1 READYThe readiness probe failsEvents: Unhealthy, check probe path and port

    AKS: logs and events

    kubectl get pods                                  # status column first
    kubectl describe pod ragapi-7d9f8c6b5-x2k4q       # Events at the bottom
    kubectl get events --sort-by=.metadata.creationTimestamp
    kubectl logs ragapi-7d9f8c6b5-x2k4q               # current container
    kubectl logs ragapi-7d9f8c6b5-x2k4q --previous    # the one that crashed
    kubectl logs deployment/ragapi -f                 # follow one pod of the Deployment
    az aks check-acr -g rg-ai -n aks-rag --acr myreg.azurecr.io   # can nodes pull?

    AKS: connectivity

    kubectl get endpoints ragapi                      # empty = selector matches no ready pods
    kubectl port-forward deployment/ragapi 8000:8000  # bypass the Service, test the pod
    kubectl run tmp --rm -it --image=busybox -- wget -qO- http://ragapi/healthz   # DNS + Service from inside
    kubectl exec -it deployment/ragapi -- sh          # check env vars and outbound access

    With Container insights turned on, logs and events also go to Log Analytics (ContainerLogV2, KubeEvents, KubePodInventory), so you can query history after the pod is gone.

    Container Apps: system and console logs

    az containerapp logs show -g rg-ai -n ragapi --type system --follow   # platform: pulls, probes, revision state
    az containerapp logs show -g rg-ai -n ragapi --type console --follow  # your app's stdout and stderr
    az containerapp revision list -g rg-ai -n ragapi -o table              # health and running state per revision
    az containerapp exec -g rg-ai -n ragapi --command sh                   # shell inside a replica

    The same logs are in the environment’s Log Analytics workspace:

    ContainerAppConsoleLogs_CL
    | where ContainerAppName_s == "ragapi"
    | where Log_s contains "Error"
    | project TimeGenerated, RevisionName_s, Log_s
    | order by TimeGenerated desc
    
    ContainerAppSystemLogs_CL
    | where ContainerAppName_s == "ragapi" and Reason_s != ""
    | project TimeGenerated, RevisionName_s, Reason_s, Log_s

    Common Container Apps causes: target port doesn’t match what the container listens on, ingress is internal when callers are outside, the registry identity has no AcrPull, a secret was changed but the revision wasn’t restarted, or a health probe points at the wrong path. The portal’s Diagnose and solve problems page checks many of these for you.

    1. 1 Status

      kubectl get pods or revision list: what state is it in?

    2. 2 Events

      describe / get events / --type system: what did the platform do?

    3. 3 Logs

      logs --previous / --type console: what did the app say?

    4. 4 Path

      endpoints, ports, DNS, ingress: can traffic get there?

    A three-step check
    Architect level Make the app easy to troubleshoot

    Log to stdout and stderr, not to files inside the container, so both platforms collect it. Add a /healthz endpoint that checks only what the app needs to serve (not every downstream dependency, or one slow database fails every probe and the platform restarts healthy pods). Fail fast with a clear message when a required environment variable is missing, so --previous shows “SEARCH_KEY is not set” instead of a stack trace three calls deep. And send traces to Application Insights with OpenTelemetry so a timeout can be followed across services.

    Real-world business scenario

    Retail

    Tailwind Traders (fictional)

    The problem
    After a release, the product-question API on AKS returned 502s. The team spent an hour reading application logs that were empty, because the new pods never got ready.
    What they used
    A runbook: kubectl get pods, kubectl describe pod for events, kubectl logs --previous, then kubectl get endpoints. Container insights sends ContainerLogV2 and KubeEvents to Log Analytics for history.
    Why that choice
    The events showed the readiness probe failing on /health while the new build served /healthz, which no application log would have shown.
    The result
    The probe path was fixed in the manifest in minutes, and the runbook now starts with events, not logs.

    When to use it and when not to

    ✓ Use it when…

    • kubectl describe and events when a pod is Pending, pulling or being killed.
    • kubectl logs --previous or Container Apps console logs when the app crashes.
    • Log Analytics queries when you need history after pods or replicas are gone.

    ✕ Think twice when…

    • Reading only application logs when the container never started.
    • Restarting pods over and over before reading why they failed.

    ↔ Alternatives to consider

    • Application Insights with OpenTelemetry for request-level traces across services.
    • Diagnose and solve problems in the portal for guided checks on Container Apps and AKS.
    Ready for more?The full lesson adds the technical explanation, when to use it, interview questions and revision notes.

    Test yourself with exercises

    5 original practice questions in the AI-200 style. Pick your answers, then check them. You will see why each option is right or wrong. Score 75% or more and this topic is marked complete.

    Question 1

    Question 1 of 5

    A pod in AKS has the status CrashLoopBackOff. You need to view the output of the container instance that crashed. Which command should you run?

    Question 2

    Question 2 of 5 · Select 2

    A pod in AKS has the status ImagePullBackOff. Which TWO commands help you determine the cause?

    Question 3

    Question 3 of 5

    A container app revision fails to start. You need to view platform messages about image pulls, probe failures, and revision provisioning for the app. Which command should you run?

    Question 4

    Question 4 of 5

    You need to write a Log Analytics query that returns the standard output written by a container app named ragapi. Which table should you query?

    Question 5

    Question 5 of 5

    Pods for a Deployment in AKS are running, but their READY column shows 0/1 and the Service receives no traffic. What should you check first?

    Interview preparation

    Say your answer out loud first, then open the model answer. Interviewers care more about your reasoning than the exact words.

    Beginner A pod shows CrashLoopBackOff. What's your first command?

    Model answer

    kubectl logs on that pod with --previous, because the current container may have only just started and have nothing useful yet. The previous container's output usually shows the stack trace, like a missing environment variable.

    Intermediate What's the difference between logs and events?

    Model answer

    Logs are what my application printed. Events are what Kubernetes did: scheduled the pod, pulled the image, killed it for failing a liveness probe, couldn't find room on a node. If the app never started, there are no logs, so events are where I look.

    Experienced developer A Container Apps revision is stuck in a failed provisioning state. How do you find out why?

    Model answer

    az containerapp logs show with --type system shows the platform side: image pull errors, probe failures, the container exiting. I'd also check az containerapp revision list for the health state and, for history, query ContainerAppSystemLogs_CL in Log Analytics filtered by RevisionName_s.

    Interviewer follows up

    And if the system logs look fine?

    You

    Then the app itself is failing, so I read --type console, or ContainerAppConsoleLogs_CL, for its own output.

    Scenario Pods are Running and Ready but the Service returns nothing. What do you check?

    Model answer

    kubectl get endpoints for the Service. If it's empty, the selector doesn't match the pod labels. If it has IPs, I check targetPort against the containerPort, then test from inside the cluster with a temporary pod and curl the Service name.

    Quick revision

    Key points

    • Logs (what the app said), events (what the platform did), connectivity (can traffic reach it).
    • kubectl logs --previous reads the last crashed container; kubectl describe pod shows its events.
    • ImagePullBackOff = wrong image or no AcrPull; check with az aks check-acr.
    • Container Apps --type system is platform logs, --type console is your app's output.
    • Log Analytics tables are ContainerAppConsoleLogs_CL and ContainerAppSystemLogs_CL; AKS container logs go to ContainerLogV2.

    Important terminology

    CrashLoopBackOff
    A pod status meaning the container keeps starting and crashing, and Kubernetes is waiting longer between restarts.
    ImagePullBackOff
    A pod status meaning the node can't pull the image, usually a wrong name or tag or missing pull permission.
    Events
    Kubernetes records of what the platform did to an object, such as scheduling, pulling, probe failures and kills.
    System logs (Container Apps)
    Platform messages about revisions, replicas, image pulls and probes, stored in ContainerAppSystemLogs_CL.
    Console logs (Container Apps)
    Your container's stdout and stderr, stored in ContainerAppConsoleLogs_CL.
    Endpoints
    The list of pod IPs a Kubernetes Service currently forwards to; empty means no ready pods match.

    Common mistakes

    • Running kubectl logs on a CrashLoopBackOff pod without --previous and seeing nothing useful.
    • Looking for application logs when the container never started; check events or system logs first.

    Exam tips

    • "Why can't the pod start or pull its image?" = kubectl describe pod / kubectl get events.
    • "See output from the container that just crashed" = kubectl logs --previous.
    • "Query Container Apps app output in Log Analytics" = ContainerAppConsoleLogs_CL.

    Five quick revision questions

    1. 1.Which kubectl flag shows logs from the previous container instance?Show

      --previous

    2. 2.Which command shows a pod's events?Show

      kubectl describe pod

    3. 3.Which Container Apps log type shows platform messages?Show

      system

    4. 4.Which table holds Container Apps console output?Show

      ContainerAppConsoleLogs_CL

    5. 5.What does an empty Service endpoints list usually mean?Show

      The Service selector doesn't match any ready pod.

    Official references

    Finished this lesson? Tick it off. Your progress is saved in this browser.

    Next up: Embeddings and Vector Search for Developers

    Studying with a friend? Send them this lesson

    It's free and needs no sign-up. Their progress saves in their own browser.

    Lesson done? Make it stick with a quick gameSort It, Match the Pairs, Lightning Round and Who Am I? Earn XP and badges. Play ❯

    Install MSDEVBUILD Azure

    Free · no account · works offline

    Save the whole course for offline ›

    Hi, I’m your Nimbus

    Your study buddy. Pick what we do next.

    MSDEVBUILD · Multi-Stack Dev Build

    Sign in to MSDEVBUILD

    One account for Azure certifications and the blog: sign in here and you are signed in on both. Your XP, streak, practice deck and certificate stay in sync on every device. Optional: everything works without an account.