azureazure-spring-cloudazure-spring-boot

Spring Boot Apps in Azure. Cannot View Logs of running App


I have a running Spring Boot App running in Azure. Unfortunately there is something wrong with one of my API calls, returning me a 500 error. See below :

In the past I can usually diagnose this within 30 seconds. I usually have a link to a log file on the server, and I can find any exception that is thrown. Things were easy in the old days :)

However in the Azure world things seem infinitely more confusing.

According to documentation I go to "Console" and select "App instance" where my running instance appears in a drop down box.

I connect with a shell. I expect to see all my logs from my spring app but I just get a blank screen.

On further digging, I realise that i have to execute a command to get to my logs. There is an "az" command I am supposed to use

az spring app logs --resource-group <Resource_group_name> --service <Service_instance_name> --name <App_name> --follow

In my situation I need to run :

az spring app logs --resource-group shapeShopResourceGroup --service shapeshop2 --name shape-shop-app --follow

However here is the problem. The "az console" will not allow me to use more than 50 characters.

Also if I just run

az spring app logs

it says that the "command is not found".

On top of all that, the az console seems to not paste text in correctly. Funny characters like "\E[200~ " appear.

I desperately need to find out what is causing my 500 error in my application. Any help appreciated. Also I am using the "consumption plan" for react apps, which only fires up an instance when the app is actively being used.

enter image description here

UPDATE: I have also tried running the log command in the cloud shell but I get a "no instances found for deployment" error.

enter image description here


Solution

  • When you run "az spring app logs" inside Azure Spring App Console, it says that the "command is not found".

    When using Azure Spring App Console, we actually get inside the docker container which hosting your application. Inside it, there is no "Azure CLI client" being installed. So we cannot run any "az" command inside Console.

    I have also tried running the log command in the cloud shell but I get a "no instances found for deployment" error.

    "az spring app logs" command is designed to check real time log stream of a active running app deployment instance.

    If the app deployment is somehow crashed or restarting, the platform won't be able to attach to the active instance to grab log stream.

    To check the App historical log, we can Query logs by using Log Analytics.

    After confirming your logging options, use the following steps to query log data:

    1. In the Azure portal, go to your Azure Spring Apps instance.
    2. Select Logs from the navigation pane.
    3. In the New Query 1 settings, enter a query such as the following example:
      AppEnvSpringAppConsoleLogs_CL
      | where ContainerAppName_s == "YourAppName" and RevisionName_s has "YourDeploymentName" and ContainerGroupName_s == "YourInstanceName"
      | limit 50
      
    4. Select Run.