Azure / webapps-deploy

Enable GitHub developers to deploy to Azure WebApps using GitHub Actions
MIT License
270 stars 193 forks source link

Kudu Sync fails with Error: EISDIR: illegal operation on a directory #204

Closed danjagnow closed 2 years ago

danjagnow commented 2 years ago

I have an ASP.NET Core Web Application based on .NET 5 that uses azure/webapps-deploy to deploy to Azure. After updating the application to .NET 6, the Azure deployment fails. The app runs fine locally on a Windows workstation.

My GitHub Actions YAML looks like this (with the app name changed):

name: Build Web App

on: [push]

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
    - name: Checkout Code
      uses: actions/checkout@1e204e9a9253d643386038d443f96446fa156a97 # v2.3.5

    - name: Install .NET Core
      uses: actions/setup-dotnet@5a3fa01c67e60dba8f95e2878436c7151c4b5f01 # v1.8.2
      with:
        dotnet-version: 5.0.402

    - name: Restore
      run: dotnet restore

    - name: Build
      run: dotnet build --no-restore --configuration Release

    - name: Publish
      run: dotnet publish --configuration Release --output './app'

    - name: 'Deploy to Azure'
      if: ${{ github.ref == 'refs/heads/main' }}
      uses: azure/webapps-deploy@0b651ed7546ecfc75024011f76944cb9b381ef1e # v2.2.3
      with: 
        app-name: myapp
        publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }}
        package: './app'

The only change to that with the .NET 6 update was the dotnet-version, which changed to 6.0.100. There were several changes in the application itself, but those all compile and run normally. During the deployment step, I now get an error:

##[group]Run dotnet publish --configuration Release --output './app'
dotnet publish --configuration Release --output './app'
shell: /usr/bin/bash -e {0}
env:
  DOTNET_ROOT: /home/runner/.dotnet
##[endgroup]
Microsoft (R) Build Engine version 17.0.0+c9eb9dd64 for .NET
Copyright (C) Microsoft Corporation. All rights reserved.

  Determining projects to restore...
  All projects are up-to-date for restore.
  MyApp.Web -> /home/runner/work/myapp/myapp/src/MyApp.Web/bin/Release/net6.0/MyApp.Web.dll
  MyApp.Web -> /home/runner/work/myapp/myapp/app/
##[group]Run azure/webapps-deploy@0b651ed7546ecfc75024011f76944cb9b381ef1e
with:
  app-name: myapp
  publish-profile: ***
  package: ./app
  slot-name: production
env:
  DOTNET_ROOT: /home/runner/.dotnet
##[endgroup]
Package deployment using ZIP Deploy initiated.
Updating submodules.
Preparing deployment for commit id '5ff86a2458'.
Generating deployment script.
Using cached version of deployment script (command: 'azure -y --no-dot-deployment -r "/tmp/zipdeploy/extracted" -o "/home/site/deployments/tools" --basic --sitePath "/tmp/zipdeploy/extracted"').
Running deployment command...
Command: "/home/site/deployments/tools/deploy.sh"
Handling Basic Web Site deployment.
Kudu sync from: '/tmp/zipdeploy/extracted' to: '/home/site/wwwroot'
Copying file: 'MyApp.Web'
Copying file: 'MyApp.Web.deps.json'
Copying file: 'MyApp.Web.dll'
Copying file: 'MyApp.Web.pdb'
Copying file: 'MyApp.Web.runtimeconfig.json'
Copying file: 'MessagePack.Annotations.dll'
Copying file: 'MessagePack.dll'
Copying file: 'Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.dll'
Copying file: 'Microsoft.AspNetCore.Identity.EntityFrameworkCore.dll'
Copying file: 'Microsoft.AspNetCore.Identity.UI.dll'
Copying file: 'Microsoft.AspNetCore.Razor.Language.dll'
Copying file: 'Microsoft.Bcl.AsyncInterfaces.dll'
Copying file: 'Microsoft.Build.Framework.dll'
Copying file: 'Microsoft.Build.Tasks.Core.dll'
Copying file: 'Microsoft.Build.Utilities.Core.dll'
Copying file: 'Microsoft.Build.dll'
Copying file: 'Microsoft.CodeAnalysis.AnalyzerUtilities.dll'
Copying file: 'Microsoft.CodeAnalysis.CSharp.Features.dll'
Copying file: 'Microsoft.CodeAnalysis.CSharp.Scripting.dll'
Copying file: 'Microsoft.CodeAnalysis.CSharp.Workspaces.dll'
Copying file: 'Microsoft.CodeAnalysis.CSharp.dll'
Copying file: 'Microsoft.CodeAnalysis.Features.dll'
Copying file: 'Microsoft.CodeAnalysis.Razor.dll'
Copying file: 'Microsoft.CodeAnalysis.Scripting.dll'
Copying file: 'Microsoft.CodeAnalysis.VisualBasic.Features.dll'
Copying file: 'Microsoft.CodeAnalysis.VisualBasic.Workspaces.dll'
Copying file: 'Microsoft.CodeAnalysis.VisualBasic.dll'
Copying file: 'Microsoft.CodeAnalysis.Workspaces.MSBuild.dll'
Copying file: 'Microsoft.CodeAnalysis.Workspaces.dll'
Copying file: 'Microsoft.CodeAnalysis.dll'
Copying file: 'Microsoft.Data.SqlClient.dll'
Copying file: 'Microsoft.DiaSymReader.dll'
Copying file: 'Microsoft.DotNet.Scaffolding.Shared.dll'
Copying file: 'Microsoft.EntityFrameworkCore.Abstractions.dll'
Copying file: 'Microsoft.EntityFrameworkCore.Relational.dll'
Copying file: 'Microsoft.EntityFrameworkCore.SqlServer.dll'
Copying file: 'Microsoft.EntityFrameworkCore.dll'
Copying file: 'Microsoft.Identity.Client.dll'
Copying file: 'Microsoft.IdentityModel.JsonWebTokens.dll'
Copying file: 'Microsoft.IdentityModel.Logging.dll'
Copying file: 'Microsoft.IdentityModel.Protocols.OpenIdConnect.dll'
Copying file: 'Microsoft.IdentityModel.Protocols.dll'
Copying file: 'Microsoft.IdentityModel.Tokens.dll'
Copying file: 'Microsoft.VisualStudio.Debugger.Contracts.dll'
Copying file: 'Microsoft.VisualStudio.Web.CodeGeneration.Core.dll'
Copying file: 'Microsoft.VisualStudio.Web.CodeGeneration.EntityFrameworkCore.dll'
Copying file: 'Microsoft.VisualStudio.Web.CodeGeneration.Templating.dll'
Copying file: 'Microsoft.VisualStudio.Web.CodeGeneration.Utils.dll'
Copying file: 'Microsoft.VisualStudio.Web.CodeGeneration.dll'
Omitting next output lines...
Error: EISDIR: illegal operation on a directory, open '/home/site/wwwroot/wwwroot/Identity/lib/bootstrap/LICENSE'
An error has occurred during web site deployment.
Kudu Sync failed
\n/opt/Kudu/Scripts/starter.sh "/home/site/deployments/tools/deploy.sh"
##[error]Failed to deploy web package to App Service.
##[error]Deployment Failed with Error: Package deployment using ZIP Deploy failed. Refer logs for more details.
App Service Application URL: http://myapp.azurewebsites.net

I tried adding a hack to delete the offending file from under the ./app folder immediately after the dotnet publish, but the error just moved to a different file. See also https://stackoverflow.com/questions/69967124/azure-app-service-net6-deploy-error-eisdir-illegal-operation-on-a-directory for another user encountering a similar issue after a .NET 6 upgrade. Any ideas about what might be going wrong?

danjagnow commented 2 years ago

Workaround: I was able to open the Kudu Remote Execution Console and delete the wwwroot folder under site:

/home>cd site
/home/site>rm -r wwwroot

After that, the deployment proceeded with the .NET 6 flavor of the application.

danjagnow commented 2 years ago

Oh, and I had to update from .NET 5 to .NET 6 under General settings under Configuration to make sure the correct framework was installed.

image

github-actions[bot] commented 2 years ago

This issue is idle because it has been open for 14 days with no activity.

rahulaga-msft commented 2 years ago

@danjagnow we will investigate this case. Between - did you try recently and is the issue still happening?

danjagnow commented 2 years ago

@danjagnow we will investigate this case. Between - did you try recently and is the issue still happening?

After the workaround I described above, I haven't encountered any further issues. I have been able to deploy several other changes to Azure with a .NET 6 codebase without further problems. But since at least one other person has encountered similar symptoms, I thought it would be helpful to document the issue.

rahulaga-msft commented 2 years ago

@danjagnow we will investigate this case. Between - did you try recently and is the issue still happening?

After the workaround I described above, I haven't encountered any further issues. I have been able to deploy several other changes to Azure with a .NET 6 codebase without further problems. But since at least one other person has encountered similar symptoms, I thought it would be helpful to document the issue.

Thanks for info @danjagnow. For now, I am closing this case, if you happen to encounter it again, you can reopen it.

rvvincelli commented 2 years ago

We are encountering this on PHP 8. Removing the site directory is an unacceptable workaround - if a workaround at all - because that breaks the service itself, of course. Please re-open this issue (you may contact me for feedback and a repro). Otherwise, suggest a proper workaround. Thanks, cc @AyoAyomide

MrGoodfix commented 1 year ago

I am encountering this same issue. I just updated a .net core 3.1 api to .net core 6. My error message is nearly identical to that of the original posters. I agree with rvvincelli that deleting the site directory is an unacceptable workaround. Even if deleting the site directory was acceptable as a workaround... the issue remains and this error should not have been closed.

rvvincelli commented 1 year ago

@MrGoodfix We were able to pinpoint the issue and find an acceptable workaround, finally. The issue is: the release script does not handle symlinks properly. Not really blaming anyone here, since symlinks are a notorious complication in Git already, and they are system-dependendent. Our solution is: avoid the symlink altogether.

This is Composer-specific for our Laravel project, but I guess it can be done in any other build system etc. In the repositories array we have added an extra symlink property, like this:

{
  "type": "path",
  "url": "./nova-components/Sharesquare",
  "options": {
    "symlink": false
  }
}

this forces the build to copy the contents of the component dir, rather than symlinking it. With this fix in place we have not encountered any other issues.

The Azure script should not fail in the first place, yet this is an acceptable workaround. cc @ayoayomide