Azure Web App, default deployment and KUDU/FTP strangeness...Where are my files?
I try to keep up with the pace of change on the Azure ecosystem, however missed one change that left me stumped for several hours yesterday.
I was deploying a quick and dirty Web App to Azure App Service that required a periodic file drop from an Azure CI/CD pipeline.
The plan was to configure the Web App, then setup a pipeline to use the Azure DevOps Pipelines FTP Task to drop the build artefacts into a folder under a directory within site/wwwroot on the Web App. Simple enough?
Setup everything, deploy the web app (from another CI/CD pipeline) and voila there is my site running on Azure. Next I triggered the pipeline with the FTP task, several minutes later the task completes 'successfully' and the FTP log shows the files were uploaded to the specified directory on the Web App.
I refresh my web app and expect to see my files, but nope, nothing?
I fire up WinSCP and FTP into the directory and can see /site/wwwroot but its empty apart from the files I just dropped via FTP, however no app files? but my apps running... mmm?
I run through the usual troubleshooting, ensure I'm using the correct user/privileges, I'm on the correct Web App etc but can't see anything untoward.
I started creating files in other directories (outside wwwroot) and can see those in both KUDU and my FTP session, so I know I'm on the correct site etc.
Some digging later, I notice a flag set under App Settings 'WEBSITE_RUN_FROM_PACKAGE' which has been set to 1 (default) when deploying from the 'Azure App Service Deploy' task on my Azure Pipeline (I'm not sure if It's the default when creating from the Azure Portal directly or using a YAML pipeline). This sounds interesting and digging a bit further lead me to this announcement on GitHub from last year.
In short, the new feature runs your Web App directly from the package zip file and not from the wwwroot. Making any changes to the actual wwwroot via KUDU or FTP will have no effect as the app isn't actually running from there. If you wish to switch back to using wwwroot rather than running from package, simply change the flag 'WEBSITE_RUN_FROM_PACKAGE' to '0', restart you app and if you refresh your FTP you should now see all off the app files listed.
This has obviously been in place for a while, and the fact I have been deploying Web Apps successfully (albeit without any need for a file drop via FTP) it had left me stumped. Hopefully this post helps anyone else running into this initially bizarre behaviour before the spend several hours troubleshooting.
You can read a good summary of the change here.