How do I set the default document of an Azure App Service when it exists in a subdirectory?

Stefan Bogdanescu

Founder & Senior Architect · 2026-06-29

Laravel Company

Mastering Deployment Paths: Setting the Default Document in Nested Azure App Services

Deploying complex web applications, especially those built on frameworks like Laravel, often introduces subtle but frustrating pathing issues. When you move beyond deploying to a simple root directory, managing the relationship between your deployment artifact location and the web server's document root becomes a significant challenge. As a senior developer, we need strategies that account for these infrastructure realities.

This post dives into the specific problem of setting the default document (index.php) when an Azure App Service is deployed from a subdirectory (e.g., \site\wwwroot\), and how to successfully reconcile the deployment process with the application's required structure.


The Root of the Conflict: Deployment vs. Serving Path

The core difficulty you are encountering stems from the separation between where Azure DevOps deploys files and where the Azure App Service (running IIS or Kestrel) serves those files from.

When you deploy a project, the deployment task places all your files into the target application directory. If your build agent targets \site\wwwroot\, everything lands there. However, for PHP frameworks like Laravel, the web server needs to know exactly which folder contains the public entry point (index.php).

The attempt to simply change the Application Directory in Azure settings (e.g., setting it to \site\wwwroot\public) resolves the serving issue but breaks the deployment integrity, as the pipeline continues to write files into the path specified in the deployment settings, leading to file overwrites or misplaced assets.

The Developer Solution: Artifact Management and Application Settings

Instead of trying to force Azure to read a subdirectory structure that conflicts with the deployment mechanism, the robust solution lies in correctly structuring your application for deployment and using environment configuration to guide the runtime. For Laravel applications, adherence to standard conventions is paramount; as noted by developers focused on clean architecture, maintaining the integrity of vendor files and public assets is crucial when deploying code such as what you would find in a modern Laravel setup from projects like those detailed at laravelcompany.com.

Strategy 1: Adhering to Framework Structure

The most reliable approach is to ensure that your deployment artifacts are placed exactly where the web server expects them, regardless of the outer subdirectory structure used for deployment staging. For Laravel, this means ensuring that index.php resides directly within the publicly accessible root folder.

If your build pipeline generates content into a staging area (\site\wwwroot\), you must ensure your final deployment step copies or moves only the necessary application files to the actual web root directory.

Strategy 2: Using Application Settings for Pathing (The Indirect Approach)

Since direct path manipulation within the Azure deployment context is proving difficult, we can use Application Settings to instruct the application runtime where to look for its entry point. This bypasses the need for complex IIS configuration adjustments and relies on Laravel's internal routing capabilities.

For example, you might set an environment variable that points to the public directory if your framework supports dynamic path resolution based on settings:

# Example of setting a custom application setting in Azure App Service
APP_PUBLIC_PATH: /site/wwwroot/public

While this doesn't change the physical file system deployment, it tells your Laravel application code where to resolve its asset paths and views, effectively forcing the framework to look inside the subdirectory structure you have deployed. This method acknowledges the deployment path while guiding the runtime environment correctly.

Conclusion

Resolving deployment path conflicts in cloud environments requires shifting focus from purely infrastructure configuration (like App Service settings) to robust artifact management within your CI/CD pipeline. By respecting the standard directory structure expected by frameworks like Laravel and utilizing application settings to bridge the gap between the physical deployment location and the logical serving root, you can achieve reliable deployments without compromising code integrity. Focus on ensuring the final deployed state is structurally sound for the web server, making the deployment process seamless and predictable.