How to delete long from web app?

Miloš Petrović 40 Reputation points
2024-04-16T09:33:12.7733333+00:00

Hi, it is about the web app logs. The purpose is to copy them to the storage account and save them for about 90 days, which there is an option and I already set it up but I want the long on the web app to be deleted after the copy has been done. Is it possible to set something like that?

Azure Storage
Azure Storage
Globally unique resources that provide access to data management services and serve as the parent namespace for the services.
3,529 questions
Azure Static Web Apps
Azure Static Web Apps
An Azure service that provides streamlined full-stack web app development.
1,175 questions
0 comments No comments
{count} votes

Accepted answer
  1. Anand Prakash Yadav 7,855 Reputation points Microsoft External Staff
    2024-04-16T12:02:41.7433333+00:00

    Hello Miloš Petrović,

    Thank you for posting your query here!

    I understand that you are trying to delete the logs from your web app after they have been copied to the storage account. Here are a couple of methods you can use:

    · You can use a PowerShell script to delete the Web App LogFile. The script first gets the publishing credentials of the web app, then it uses these credentials to authorize a request to the Kudu API, which can be used to manage and configure your Azure Web App.

    · Another way to handle this is by creating a CRON triggered WebJob that runs on a daily or weekly basis. WebJobs run on the same App Service plan which means you can use a simple PowerShell script to delete old log-files created by your App Service.

    Further details: https://stackoverflow.com/questions/52800853/how-to-clean-up-azure-web-app-logfiles-directory

    Please be careful when deleting files from your web app. Deleting certain files can cause issues with your app. Always make sure to only delete log files and not any configuration or necessary files for your app to run.

    I hope this helps! Please let me know if the issue persists or if you have any other questions.

    Please do not forget to "Accept the answer” and “up-vote” wherever the information provided helps you, this can be beneficial to other community members. 

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.