Azure App Service Storage

Each app service storage tier provides a specific storage quota to use for hosting your app artifacts (code, media assets … etc.).

If you are using the smaller tiers (Dev\Test) you will be sensitive to storage limits more than higher tiers (production and isolated) but this also depends on your application.

At the time of writing this article, this is how much storage you can get per tier:

Azure App Service tiers – Storage options

For more information and the latest quotas and prices go to:

https://azure.microsoft.com/en-us/pricing/details/app-service/windows/

Some applications use the web server storage to store temp files that gets generated in the lifecycle of the web application. In a lot of scenarios, it would be better to use a different type of storage away from the web server but in certain cases it makes sense. Either way, I’m not going to touch on this topic in this article but I wanted to highlight that if your application is writing files to the webserver – in this case the app service in Azure – make sure you clean them up periodically.

 You don’t want to run out of storage in your app service, you also don’t want to pay for a higher tier just because you cannot keep your storage under control.

Other than your code being the main reason to periodically increase the size of your app service there are other things that can cause this to happen too, some are obvious, and some aren’t.

In this article I will highlight some of the potential contributors to storage increases in Azure app service and how to get that under control.

Before we go there, its good to know few important basics.

Each app service is hosted in an app service plan. Think of the app service plan as a virtual web farm that hosts your code. The app service is your application virtual folder (e.g. wwwroot folder).

That means if you have multiple app services hosted on a single app service plan, all the app services will share the allowed storage for that app service plan.

How much storage is my app consuming?

First thing you usually need to know to be able to address a storage problem, is where you stand in terms of storage. How much storage your apps are consuming from your app service plan allocated storage.

I find the best place to see that information is to browse to the app service plan itself from the Azure portal. Here is how:

Go to https://Portal.Azure.com

Type “app service plan” in the top center search box then select App Service plans under Services:

Search for App Service plans in the Azure Portal

Then select the app service plan in question. From the menu of the app service plan select File system storage under Settings

This will give you a nice graph that shows everything you need to know:

App Service Plan – Storage consumption

Now you know exactly which app is consuming what under your app service plan.

What to watch out for

What are the things that you need to watch out for that might be silently increasing your storage?

Here is a list:

  1. Your code! We talked about this above.
  2. Old packages from prior deployments (especially if you are building a single page web app SPA)
  3.  Old binaries that are no longer needed
  4. Localized binaries for languages your app doesn’t support

First thing is to get the items listed above under control.

Secondly, make sure you don’t have anything in your build or deployment process that might be inflating your storage for no reason. For that, I will provide two common tips to make sure your continuous deployment (whether its automated CD or manual) doesn’t contribute to the storage problem.

If you are using Visual Studio to publish your code, edit the publish profile settings and make sure to select Remove additional files at destination under File Publish Options under Settings

Publishing Web App from Visual Studio – Remove additional files option

This will ensure to delete any unwanted files in the app service storage that is not a product of your new build. Obviously, if you are not the developer of the app, you may want to check with the developers responsible of the application to make sure they’re not creating some content on the app service needed by the app outside the build process since this option will remove that content and potentially break the app logic. The odds are the person deploying the app using VS will be the developer 😊

If you are working on a more mature project and use a CD tool like Azure DevOps to do continuous delivery for example, make sure to implement a task to clean up the app service storage before deployment. That can be done in Azure DevOps native App service deployment task with a setting (if you use Web deploy):

Under Additional Deployment Options | Select Publish using Web Deploy | then select Remove additional files at destination

Azure DevOps pipelines – Remove additional files option

Cleanup

What if your app service is already taking too much space and you want to clean it up manually. There are multiple places where you can do that at:

  1. Browser: Navigate to the Azure portal and go to the app service in question, under Development Tools

Navigate to App Service Editor (Preview) which will take you to the following URL https://[App_Service _Name].scm.azurewebsites.net/dev/

App Service Editor – Manage files

Or navigate to the Kudo portal (Advanced Tools) which will take you to the following URL

https://[App_Service _Name].scm.azurewebsites.net/

Azure App Service – Kudu portal

From there you have few options:

UI, go to Tools | Zip Push Deploy

This gives you a nice UI to navigate through your app content, delete and add files …etc.

Kudu – Manage files

Console Debug console | PowerShell

Kudu Portal – PowerShell

If you are an old DOS dude like me you can go to Debug console | CMD

Kudu – Command Line

In all the above web methods you will be able to browse your web app content and delete any files as needed.

2. Thick client or IDE, you can do the following in Visual Studio:

Open the Server Explorer, connect to your Azure subscriptions then browse your App Service plan | app service files:

Visual Studio – Server Explorer

3. Use your favorite FTP client with the app service SFTP credentials

App service is still too big after deleting my code

One thing that some developers may run into, is that the app service size doesn’t go down as they delete all their deployment code. There are other things that may contribute to the size of your app service but not necessary part of your app code. This is what I call none-obvious stuff, one of the most common would be site extensions.

You may have a few site extensions installed in your app service that are not being utilized and that is what is consuming a lot of your app service storage. For example, the .NET Core 2.2 libs are big, they can be about 300 MB per version.

To find out which extensions are installed, navigate to the Azure portal and select the app service in question then go to Extensions | under Development Tools:

Make sure you don’t have any unwanted extension

App Service – Extensions

Hope that helps

Leave a Reply

Your email address will not be published. Required fields are marked *