Azure / webapps-deploy

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

Deploy to web app does not working for .NET 8 and Linux based deployment - azure/webapps-deploy@v3 #396

Open nikunjbanker opened 8 months ago

nikunjbanker commented 8 months ago

We are using GitHub Action for deploying to Azure Web App verison 3 - azure/webapps-deploy@v3. Detail about our WebApp:

Dotnet SDK version: .NET 8 - dotnet-version: 8.x Platform: Linux

Below steps in our workflow not working:

- uses: azure/webapps-deploy@v3
      id: deploy-to-webapp
      with:
        app-name: ${{ vars.PP_NAME }}
        package: ${{ steps.download-artifact.outputs.download-path }}
        clean: false
        restart: false

Using azure/webapps-deploy@v3 - Github action getting below error:

##[debug]Initiated deployment via kudu service for webapp package : /home/runner/work/_temp/temp_web_package_7365615165970218.zip
Package deployment using OneDeploy initiated.
##[debug]setting affinity cookie ["ARRAffinity=*******;Path=/;HttpOnly;Secure;Domain=******.scm.azurewebsites.net","ARRAffinitySameSite=*****;Path=/;HttpOnly;SameSite=None;Secure;Domain=******.scm.azurewebsites.net"]
##[debug][POST] https://*******.scm.azurewebsites.net/api/publish?async=true&deployer=GITHUB_ONE_DEPLOY&type=zip&clean=false&restart=false&message=_______slotName%22%3A%22production%22%2C%22commitMessage_____
##[debug]encountered request timedout issue in Kudu. Retrying again
******
Error: Failed to deploy web package to App Service.
Error: Deployment Failed, Error: Failed to deploy web package using OneDeploy to App Service.
Conflict (CODE: 409)

As a workaround, we have tried by directly executing PowerShell command, but its also not working - by creating zip and provided zip file to deploy using Publish-AzWebApp PS command:

   - name: Create Zip
      shell: pwsh
      run: Compress-Archive -Path ${{ steps.download-artifact.outputs.download-path }} -Destinationpath ./myWebApp.zip

    - name: Run Azure PowerShell inline script
      uses: azure/powershell@v1
      with:
        inlineScript: |
          Publish-AzWebApp -ResourceGroupName ${{ vars.RG_NAME }} -Name ${{ vars.WEBAPP_NAME }} -ArchivePath ./myWebApp.zip -Timeout 1000000 -Confirm:$false -Force
        azPSVersion: "latest"

Using PowerShell command, its giving below error:

/usr/bin/pwsh -NoLogo -NoProfile -NonInteractive -Command $env:PSModulePath
/usr/share:/home/runner/.local/share/powershell/Modules:/usr/local/share/powershell/Modules:/opt/microsoft/powershell/7/Modules
Initializing Az Module Complete
Running Az PowerShell Script
/usr/bin/pwsh -NoLogo -NoProfile -NonInteractive -Command /home/runner/work/_temp/*****.ps1
Publish-AzWebApp: /home/runner/work/_temp/*****.ps1:2
Line |
   2 |  Publish-AzWebApp -ResourceGroupName rg-test -Name a …
     |  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Deployment failed with status code GatewayTimeout
Error: Error: The process '/usr/bin/pwsh' failed with exit code 1

It seems, there is an issue while deploying .NET 8 - ASP.NET Core Web application to Linux based App Service. Any workaround or solution will be helpful.

Checked /wwwroot directory using bash shell as well but it also empty.

wc-whiteheadd commented 7 months ago

We are having the same issue since upgrading to NET 8 for our function apps. After deploying via the CICD it simply wipes the app plan for some reason.

wc-whiteheadd commented 7 months ago

Just to come back to this as i now know why its broken and how to fix it.

Since the latest .net 8 functions, they have changed how the compiled output works and they now create an ".azurefunctions" folder which holds the functions and references inside it. Whats really important about this is by default most compression libraries out there actually don't defaulty include folders that start with a "." in their name as in normal context, these folders are reserved for hidden directories. This means if most peoples CICD are ziping the release build up and then deploying it using webbapps, unless you override the default zipping logic, the ".azurefunctions" folder will not be zipped up along with your build and it will suddenly wipe all your azure functions upon a deployment as its missing the files required.

To fix this, when the zipping process occurs you will need to specifically specify to include the ".azurefunctions" directory, this will force the compression library to include it regardless of the fact that it starts with a "." in its name and it will solve the problem.

Hope this helps someone who comes across this.

alborzmgm commented 3 months ago

Is there any fix for this issue? I use az webapp deployment command and see the same problem.

davidenrescobedo86 commented 2 months ago

Downgrade to 7.