]> Azure App Service piling up deployment zips 🌐:aligrant.com

Azure App Service piling up deployment zips

Alastair Grant | Wed 6 Jul 2022

When deploying to Azure App Service, either directly as an app, or through a derived service like a function app, you have the option to deploy as a Zip package.  There are advantages to doing it this way, and often the default for build pipelines to produce.

The problem is, when using Azure DevOps to release into an environment, the zip files get new names unique to the release.  And the old ones are left there, so you can rapidly find yourself in the position where you have no disk space left and a lot of old zip files.  Helpfully you don't get a useful error when deploying and receive a generic:

Failed to deploy web package to App Service. Internal Server Error (CODE: 500)

I have to thank Mark Harrison for finding this fix, as it's obscurely hidden away.

The deployment is done by Kudu, which is the engine that does various deployment related tasks.  Among the various settings is one called SCM_MAX_ZIP_PACKAGE_COUNT.  Setting this to one will keep only the most recent, where by default it'll keep five.  This can be set in the Azure App Service Configuration page - which is slightly different to a local appsettings.json file.  I'd recommend updating your ARM/Bicep/Whatever templates to include this setting.

Breaking from the voyeuristic norms of the Internet, any comments can be made in private by contacting me.