Thursday, April 5, 2018

Deleting old files on Azure web app (app service)

Introduction

It is going to be a short post :)
In Azure we usually use application insights or something similar to keep track of your logs. If for some reason you like to keep everything also in log files, for example in App_data you will have a lot of files in no time. Usually the size is not that much matter since you have 100 GB on your disk, but it is also annoying that you have to look into thousands of files (usually 1 file per day per scaled instance).

Where are my files

You probably know it already since you are trying to delete them :) but for people who have searched for something else, lets say your app service is in test.azurewebsites.net/ you can access the disk using test.scm.azurewebsites.net/ 


Then you can click on "Debug console" from top menu and click on CMD to see all folders and files. To visit the place that your files have been hosted just go to Site> wwwroot



The simple solution

One simple solution is to delete the old files that you know you are not going to need. For example you might have a policy to say you don't care about what has happen more than 30 days ago. 

How?

Well, basically it is Windows so you can simply use command prompt's commands to do stuff. 
Use this command to see the list of the files older than 30 days
forfiles -s -m *.* -d -30 -c "cmd /c eco @file"

If you were happy with the results, change eco to del to delete those files:
forfiles -s -m *.* -d -30 -c "cmd /c del @file"

23 comments:

  1. Great blog and i gathered lots of information which helped me in better way. Azure App Service is one of the common and most used services. While it is possible to immediately deploy apps, jobs etc., to the app service, a common factor that baffles decision makers is the wide spectrum of the tiers (options of plans) available in the marketspace. Impiger makes your way better with their incredible service. To know more details,visit: https://www.impigertech.com/blog/azure-app-service/

    ReplyDelete
  2. Can we achieve same thing for any specific folder?

    ReplyDelete
  3. Hi nice post.vr it solutions offering azure devops training in hyderabad we offer online and classroom trainings. if you are looking azure devops training right place eto choose vr it solutions.contact @9032734343
    BEST AZURE DEVOPS TRAINING
    AZURE DEVOPS TRAINING IN HYDERABAD
    AZURE DEVOPS ONLINE TRAINING

    ReplyDelete

  4. Thanks for Sharing This Article.It is very so much valuable content. I hope these Commenting lists will help to my website
    top workday studio online training

    ReplyDelete
  5. Great article and best article i have seen today. Keep updating
    Microsoft azure course

    ReplyDelete
  6. Thanks for sharing excellent information. Your website has very useful information. I’m impressed by the details that you have in this article.

    ReplyDelete
  7. Nice blog
    Enhance your job application with our professional Job Application Form Writing Service Ireland. Our expert team ensures your application stands out, maximizing your chances of success. Trust us for meticulous attention to detail and tailored solutions that leave a lasting impression on employers.

    ReplyDelete
  8. I appreciate your assistance. The information you provided is valuable and significantly contributes to my research efforts. Thank you for sharing such useful insights.
    Bigg Boss 8 Telugu Voting

    ReplyDelete