Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to access Azure App Service application log to check Docker Compose errors?

I am a newbie at Azure and this is my first question at StackOverflow. I have a problem on deploying new Azure App Service with Multi-Container Docker (Linux) using Docker Compose. Unfortunately, I can't access my application log because there are unknown errors. I only change the configuration to use my private registry and docker-compose configuration, other settings stay at their defaults. I am using Azure for Students plan so opting in to 1:1 expert support is not an option.

My app services basically consists of 4 containers: webservice (Django REST Framework), comprof (VueJS), raspisample (Express), and db (PostgreSQL). I am using GitLab's Docker Registry (registry.gitlab.com), and it is a private registry (images aren't available publicly). Here are my docker-compose.yml file.

version: '3'

services:
  webservice:
    image: registry.gitlab.com/something/webservice:latest
    restart: always
    working_dir: /opt/webservice
    environment:
      - DEBUG=false
      - DATABASE_URL=postgresql://postgres:postgres@db:5432/postgres
      - PREDICTOR_URL=https://something-predictor.azurewebsites.net
      - CACHE_DIR=/var/cache
      - SECRET_KEY="**omitted**"
      - LOG_DIR=/var/log/webservice
      - UPLOADS_DIR=/var/uploads
      - ACCESS_LOG=/var/log/webservice/access_main.log
      - ERROR_LOG=/var/log/webservice/error_main.log
    ports:
      - "81:80"
    volumes:
      - webservice_data:/var/log/webservice
      - webservice_data:/var/cache
      - webservice_data:/var/uploads
    depends_on:
      - db
    networks:
      internal:
  comprof:
    image: registry.gitlab.com/something/company-profile:latest
    restart: always
    working_dir: /opt/comprof
    environment:
      - WEBSERVICE_URL=http://webservice:81
      - RASPI_SAMPLE_URL=http://raspisample:82
      - PREDICTOR_URL=https://something-predictor.azurewebsites.net
      - ACCESS_LOG=/var/log/comprof/access_main.log
      - ERROR_LOG=/var/log/comprof/error_main.log
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - comprof_data:/var/log/comprof
    depends_on:
      - webservice
    networks:
      default:
      internal:
  raspisample:
    image: registry.gitlab.com/something/local-webservice:latest
    restart: always
    working_dir: /opt/sample
    environment:
      - WEBSERVICE_URL=http://webservice
      - ACCESS_LOG=/var/log/raspi/access_main.log
      - ERROR_LOG=/var/log/raspi/error_main.log
    ports:
      - "82:3000"
    volumes:
      - raspisample_data:/var/log/raspi
    networks:
      internal:
  db:
    image: postgres
    restart: always
    environment:
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=postgres
      - POSTGRES_DB=postgres
    volumes:
      - db_data:/var/lib/postgresql/data
    networks:
      internal:

networks:
  default:
  internal:
    internal: true

volumes:
  webservice_data:
  raspisample_data:
  comprof_data:
  db_data:

This docker-compose configuration only fails at my Azure App Services. I have another VM at my college and this configuration works fine there. I also tried at my own laptop and it also works fine. At Azure, here are the error message:

:( Application Error
If you are the application administrator, you can access the diagnostic resources.

Azure Error Message (Picture)

When I try to troubleshoot this problem on the app settings > Container Settings > Logs, it shows me this one line error:

Error in retrieving logs.

I also retrieved same error when accessing log via Log Streams. I have enabled Application Logging on App Service logs menu, but it has no effect whatsoever. I also can't access Azure's suggested link to Docker logs, it just loads forever and returned connection timeout error after 15 minutes of loading.

The question is: is there anything wrong with my docker-compose.yml? Or is there anything wrong with my Azure App Service's configurations? Thank you.

like image 908
Ichlasul Affan Avatar asked Oct 20 '19 04:10

Ichlasul Affan


People also ask

What is the command to access the application logs container?

To view logs from your application code within a container, you can use the az container logs command.


1 Answers

To access your container logs when using docker-compose.yml you have to access

https://.scm.azurewebsites.net/api/logs/docker

for each container you get a JSON-object containing the url to the respective logfile:

[
   {
      "machineName":"RD00XYZYZE567A",
      "lastUpdated":"2018-05-10T04:11:45Z",
      "size":25125,
      "href":"https://<app-name>.scm.azurewebsites.net/api/vfs/LogFiles/2018_05_10_RD00XYZYZE567A_docker.log",
      "path":"/home/LogFiles/2018_05_10_RD00XYZYZE567A_docker.log"
   }
]

copy the link in "href" and you get your logfile.

Source: https://docs.microsoft.com/en-us/azure/app-service/containers/tutorial-multi-container-app#find-docker-container-logs

like image 137
Thomas Avatar answered Sep 26 '22 20:09

Thomas