yaml.net-8.0azure-pipelines-yaml

.NET 8 app not extracting after Zip deploy


This YAML for a .NET 8.0 C# Web App is based on content from Tony Box (MSFT) and Grok:

- task: AzureWebApp@1
  inputs:
    azureSubscription: $(azureSubscription)
    appType: 'webAppLinux'
    appName: $(appName)
    package: '$(Build.ArtifactStagingDirectory)/app.zip'
    deploymentMethod: 'zipDeploy'
    appOffline: true
  displayName: 'Deploy (Zip Deploy)'

As expected, it places a file named CIGraph.zip in the /home/site/wwwroot directory of the Debian 12 GNU\Linux server that will host the web app. Unfortunately, it doesn't seem to extract that CIGraph.zip file and the website does not work.

Interestingly, if I manually unzip the CIGraph.zip file inside /home/site/wwwroot, the website starts working as expected. I've asked a few AI agents about why my *.zip package isn't extracting on the "Deploy (Zip Deploy)" step shown above, and they seem to lead me on wild goose chases that either need unnecessarily complicated extraction scripts or require me to switch to "Run From Package" mode.

What is the easiest way to modify the above task (or add an extra one) so that my CIGraph.zip file extracts into /home/site/wwwroot during or after the "Deploy (Zip Deploy)" step?


Solution

  • Check if there is any step in your pipeline job is set to archive the build artifact files as ZIP repeatedly. For example, the ArchiveFiles@2 task. If so, remove the step.

    In the pipeline, you can use the "dotnet publish" command to build and archive the build artifact files as a ZIP file just once. Then use the AzureRmWebAppDeployment@5 or AzureWebApp@1 task to deploy the web app to Azure via ZIP deploy.

    Below is sample as reference:

    steps:
    - task: DotNetCoreCLI@2
      displayName: 'dotnet publish'
      inputs:
        command: 'publish'
        publishWebProjects: true
        arguments: '-c Release -o $(Build.ArtifactStagingDirectory)'
    
    - task: AzureRmWebAppDeployment@5
      displayName: 'Deploy to Azure'
      inputs:
        ConnectionType: 'AzureRM'
        azureSubscription: 'MyArmConnection'
        appType: 'webAppLinux'
        WebAppName: 'myWebApp'
        packageForLinux: '$(Build.ArtifactStagingDirectory)/**/*.zip'
        DeploymentTypeLinux: 'zipDeploy'