Accessing log files inside docker container - azure

I have a tomcat Docker image -- source
This image has a sample war file that logs some data in a tomcat folder -- in the instance of this image in tomcat/logs
I am deploying this image as a web app using Azure containers -- and that works great, but I was wondering if there was a way to access that tomcat/logs folder?
I can FTP to the web app but I cannot access to the files in the Docker container.
Is there a way to do it?

You first need to enable them. To enable application logging for Linux apps or custom containers in the Azure portal, navigate to your app and select App Service logs. In Application logging, select File System > In Quota (MB), specify the disk quota for the application logs > In Retention Period (Days), set the number of days the logs should be retained > When finished, select Save.
Then you can see container logs in your App Service > Monitoring > Log stream
You can use Kudu to view the logs -Linux/container apps:
https://.scm.azurewebsites.net/api/logs/docker
You may also leverage App Service diagnostics.
To access App Service diagnostics, navigate to your App Service app in the Azure portal> In the left navigation, click on Diagnose and solve problems – Checkout the tile for “Diagnostic Tools” and “Availability and Performance” > "Application Logs" title.

Related

Azure Web Jobs unable to read configuration of Azure App Service

I am currently deploying a C# console app as a Continuous Azure Web Job to an Azure App Service and I am using the Azure Web Jobs SDK 3.X(https://learn.microsoft.com/en-us/azure/app-service/webjobs-sdk-how-to).
The Web Job successfully deploys to the Azure App Service but the status of the Web Job is "Pending Restart". When I check the logs, the error I see is that a configuration value is being read in as NULL. I am setting this value in the App Service's configuration/Application Settings page but it seems my Web Job is unable to read it. Do these settings need to be set during deploy? Or do I need to be setting these configuration values in a different location?
My issue was that my app thought that my environment was Develop and it was looking for the appsettings.Development.json file. Once I corrected that issue, it looks like I am reading in my app settings correctly.

How to delete files created by Azure app service automatically

My app service has an export scenario which extracts data from backend and writes to app service file storage first and egress the data to the blob later. These files are huge and sometimes more than 1GB of size. The current SKU of the app service is supporting 250GB and often running into storage problems because of these temp files creation.
Is there a way I could delete these files programmatically through kudu or may be by exposing another delete end point to delete selective files from the server?
How to delete files created by Azure app service automatically
You can delete files in Azure Web app service created by using kudu console by following the below work-around:
Then click on GO:
Then click on Debug Console:
Then click on CMD:
Then Click on delete:
Other References to delete files are:
Deleting old web app logs using Azure Web Jobs and PowerShell (swimburger.net)
Interacting with Azure Web Apps Virtual File System using PowerShell and the Kudu API – Kloud Blog

Is there any way of Accessing/ fetch application logs of AKS (Azure kubernetes Services) from outside or browser?

I have deployed a web application on Azure Kubernetes Service (AKS). I want to generate Application logs of deployed web application of cluster like Log folder. I want to access those logs from LOG folder through browser or any other solution which I can easily share with developers to access logs from their system as well.
You can use the logging options, cloud-native solutions like fluentD and you can push the logs from LOG folder to Elasticsearch or Azure logging solution and you can watch the logs into dashboard.
Fluentd : https://www.fluentd.org/
Check out more at : https://logz.io/blog/kubernetes-log-analysis/

Azure App Service Kudu tool "LogFiles" Deleted Automatically -- app service for container (linux)

I hosted my dotnet core app on app service for containers and I'm using the standard logging to log http request, but when I check my log files from kudu, it seems that files deleted automatically each day to add new day-file
As example,
on 25/10/2020 I got those files
(22-10-2020_docker_log, 19-10-2020_docker_log, 25-10-2020_docker_log)
and on 26/10/2020 I got those files
(22-10-2020_docker_log, 19-10-2020_docker_log, 26-10-2020_docker_log)
Why this happened? is log files deleted daily? I think it should never deleted, isn't it?
Thanks in advance.
Enable application logging by navigating to your app, select App Service logs.
In Application logging, select File System.
In Quota (MB), specify the disk quota for the application logs. In Retention Period (Days), set the number of days the logs should be retained.
Click Save.

Can azure app service delete folders that created by another instance?

We have Azure app service that is configured auto scale up/down depending on some criteria.
Application hosts in app service will download big files from Azure blob storage to
local 'D:\home' to process
Application will clean up those temp files after successfully/failed process.
However, when app service scale down, the temp files downloaded by scaled down app service are not cleaned up, and eventually run out of space for those remaining app service.
Questions:
Can remaining running app service delete those files/folders that were downloaded/created by another app service instance (and those app services instance are gone because of scale down)? All of those files/folders downloaded/created be different app service instances are in the same 'D:\home'.
If there is a way to detect app service is shutting down, clean up those temp files/folder before it finally shut down?
1- There's no ready to use feature like that. You can try implementing one using alerts from Azure Monitor and / or create a WebJob that will keep monitoring the temp folder
https://learn.microsoft.com/en-us/azure/azure-monitor/platform/alerts-classic-portal
2- as far as I know, there's no event that is raised for that.

Resources