Costa Rica
Last updated: 2025-08-27
Contains two scenarios to compare temp file decay behavior in Azure Functions. The goal is to demonstrate how different configuration and coding practices affect temporary file accumulation and disk usage.
Important
Overview about how Azure Function Apps operate within App Service infrastructure, focusing on temp file creation, storage, and management. Runtime behavior, deployment impact, and optimization strategies. For official guidance, support, or more detailed information, please refer to Microsoft's official documentation or contact Microsoft directly: Microsoft Sales and Support
List of References (Click to expand)
- Kudu service overview
- log levels types
- How to configure monitoring for Azure Functions
- host.json reference for Azure Functions 2.x and later
- Sampling overrides %
- Sampling in Azure Monitor Application Insights with OpenTelemetry
- Azure Functions deployment technologies
- Run your Azure Functions from a package file
- Continuous delivery by using Azure DevOps
- Continuous delivery by using GitHub Actions
- Best practices for reliable Azure Functions
- Improve the performance and reliability of Azure Functions
- Accessing the kudu service - GitHub repo
- Understanding the Azure App Service file system - GitHub repo
Table of Content (Click to expand)
- Scenarios
- How to Compare Results
- Deployment Approaches
- High-Decay -
Writable Approach + Configs
- Optimized -
Mounted Package Approach + Configs
- High-Decay -
- High Decay test: Test rapid temp file accumulation and disk decay
- Recommendations for Optimized configuration: Test how to minimize temp file accumulation
When deployed, two scenarios were compared by:
- Monitoring disk usage in Kudu (
https://<function-app-name>.scm.azurewebsites.net/DebugConsole
) - Running load tests against both function apps
- Observing memory usage and response times
- Checking temp directories for file accumulation
Each scenario includes detailed deployment guides that explain different approaches:
- High-Decay (Writable Approach), click here for quick deployment guide
- Optimized (Mounted Package Approach), click here for quick deployment guide
The combination of writable deployment, intensive logging, and full diagnostics causes Azure Functions to generate and buffer a large amount of telemetry and log data in local temp storage. This leads to rapid disk usage growth, temp file accumulation, and eventual disk decay. Click here to go to High-Decay test approach
- Deployment Method: Standard deployment (extracted to wwwroot)
- File Access: Files are writable by the Function App
- Pipelines: Azure DevOps pipeline with standard deployment
Important
Overall, the problem with standard/writable deployment with intensive logging:
- Intensive logging and diagnostics (full Application Insights, detailed diagnostics, verbose log level) generate a large volume of log and telemetry data.
- Writable deployment (
WEBSITE_RUN_FROM_PACKAGE = 0
) means the function app runs from extracted files inwwwroot
, allowing the app and platform to write files locally. - Azure Functions and the platform buffer logs, telemetry, and temp files in the local file system, specifically under
C:\local\Temp
andD:\local\Temp
(on Windows plans). - Telemetry and diagnostic logs are first written to local temp storage before being sent to Application Insights or other destinations.
- High load and verbose logging cause rapid accumulation of files in these temp directories.
- Disk usage grows over time as temp files, logs, and telemetry buffers accumulate, especially if the app is under sustained or bursty load.
- Some files may remain locked or not be cleaned up automatically, even after a function app restart, leading to "disk decay" (progressive loss of available disk space).
- Performance degrades as disk fills up, and the app may eventually fail if the temp storage is exhausted.
The combination of mounted (read-only) deployment, optimized logging, and minimal diagnostics causes Azure Functions to generate and buffer very little telemetry and log data in local temp storage. This prevents disk usage from growing, avoids temp file accumulation, and eliminates disk decay. Click here to go to Optimized test approach
- Deployment Method: ZipDeploy with
WEBSITE_RUN_FROM_PACKAGE=1
- File Access: Files are read-only (mounted from zip)
- Pipelines: Azure DevOps pipeline with ZipDeploy or GitHub Actions workflow
Important
Overall, the benefit with optimized (mounted) deployment and minimal logging:
- Minimal logging and diagnostics (Application Insights with sampling, reduced diagnostics, less verbose log level) generate far less log and telemetry data.
- Mounted deployment (
WEBSITE_RUN_FROM_PACKAGE = 1
) means the function app runs from a read-only mounted package, preventing the app and platform from writing files towwwroot
. - Azure Functions and the platform buffer far fewer logs and temp files in the local file system, reducing writes to
C:\local\Temp
andD:\local\Temp
. - Telemetry and diagnostic logs are sampled and sent directly to Application Insights or other destinations, with minimal local buffering.
- Even under high load, temp file accumulation is negligible because the app and platform cannot write to the mounted package and logging is optimized.
- Disk usage remains stable over time as temp files, logs, and telemetry buffers are minimized and cleaned up efficiently.
- Restarts are rarely needed for disk cleanup, and locked files are uncommon.
- Performance remains consistent even under sustained load, as disk space is preserved and temp file decay is prevented.