microsoft / azure-pipelines-tasks

Tasks for Azure Pipelines
https://aka.ms/tfbuild
MIT License
3.51k stars 2.62k forks source link

Azure App Service Deploy - Deploying to virtual directory wipes contents of site\wwwroot #11661

Closed brettkc closed 4 years ago

brettkc commented 5 years ago

Question, Bug, or Feature?
Type: bug

Enter Task Name: Azure App Service deploy (v4.*)

Environment

Azure DevOps (hosted agent) Agent Specified: windows-2019

Issue Description

In Azure we've got an Azure App Service resource setup with the following path mappings: / => site\wwwroot (Type: Application) /foo => site\foo (Type: Application)

Basically a static web client is hosted at the root and a .NET core 3.0 API being hosted at /foo. The client is deploying fine to the root but anytime we deploy the .NET core project to virtual directory /foo it also completely wipes the contents of site\wwwroot. Note that deploying the client does NOT wipe site\foo.

The dotnet command being run to package the .NET core project is: --configuration $(BuildConfiguration) --output $(Build.ArtifactStagingDirectory) --runtime win-x86 --self-contained true

The output from that is what is used as the source folder for the task in question Azure App Service Deploy.

Note: Publishing to app service from Visual Studio doesn't wipe the root for what it's worth

Task Settings: image

Task logs

Log (some obfuscation where necessary): 3_Azure App Service Deploy Dev.log

brettkc commented 5 years ago

I'll add that after trying many things to get this to work as expected, reverting this task to the previous version appears to work as intended. Issue appears to only exist in the latest version of the task.

eaarora-ms commented 5 years ago

@brettkc Can you please confirm if it's still happening with the latest version. My assumption is that the latest changes should have fixed the problem.

eaarora-ms commented 4 years ago

We are working on a potential fix. Will let you know the updates.

arjgupta commented 4 years ago

We have discovered while making certain app settings, kudu package handling can misbehave. We are under discussion with app service team and will update this thread as and when the fix is made.

eaarora-ms commented 4 years ago

This is an issue with one of the REST APIs (Update App Settings API to be specific) and we are working with the App service team to get this resolved.

Sorry that this is taking longer than expected.

HansOlavS commented 4 years ago

@eaarora-ms, This might be an important clue: I'm seeing this error consistently on a new Azure Functions app I made today, but not on older Azure Functions apps. In my deploy pipeline everything checks out on the old Azure Function apps, but on the new one I created today I'm not able to get the deploy to work. And the SitePackages folder is empty and I get the same wwwroot "FAILED TO INITIALIZE RUN FROM PACKAGE.txt" file.

EDIT: I just downgraded the Azure Functions app from version ~3 to ~2 and the deploy worked. It might've just been a fluke, but maybe that's the culprit?

eaarora-ms commented 4 years ago

@HansOlavS We figured out it is happening for the new apps and the older ones are not creating problems but the version thing is new. Thanks for the help!

HansOlavS commented 4 years ago

@eaarora-ms Cool. FYI, the first thing I checked was to see if the runtime versions in Kudu were different, but they're exactly the same - even the commit hash.

HansOlavS commented 4 years ago

I have to report that one of my Azure Function apps which is version ~2 is now showing issues with deployment where the "Run From Package"-deployment isn't deploying any zip-file and not changing anything at all. Everything is green and looks fine in Azure DevOps, but when I check the actual site content and SitePackages folder nothing had changed. So I guess the version thing might have been a fluke, after all.

SumiranAgg commented 4 years ago

@HansOlavS Can you please open new issue for this. Looks like we are digressing from the main thread about wiping up wwwroot on deployment to virtual directory.

@brettkc The issue is happening since the first deployment to root (site/wwwroot) is done via Run From Package and deployment to virtual directory is done via Web Deploy. Can you try deploying first time using Web Deploy as well and share results. You can go to "Additional Deployment Options" section and select Web Deploy and continue.

SumiranAgg commented 4 years ago

We have confirmed above workaround with app service team as well. The recommendation is to not mix RunFromPackage deployment technique with others. We follow below auto-detect logic in our task: image Ref: https://github.com/microsoft/azure-pipelines-tasks/blob/master/Tasks/AzureRmWebAppDeploymentV4/README.md#deployment

For now multiple app deployment on a single app service is not supported via Kudu. hence, we suggest doing both deployments through web deploy. You can select the option in task as under: image

We are closing the issue for now. Please feel free to comment/ re-open if required.

enriquin commented 4 years ago

Hi, I'm suffering the same issue:

Both deployments are being done using ZipDeploy (ths contents are static websites created with Jekyll), If I deploy to the "root" site everything works OK (no files from other virtual apps are deleted), but if I deploy the app in the child virtual application (hosted in "/help") the contents of the main site are erased.

Any update on this?