Bibberty
Bibberty

Reputation: 4768

Azure YAML Deployment failing with "Error: Failed to deploy web package to App Service. Conflict (CODE: 409)"

Hoping someone has seen this also. Our last successful build was on Dec 6th 2019. New deployment attempts are failing at the deployment step (Same issue in the Build and Release pipelines).

Error is reported as follows:

Got service connection details for Azure App Service:'OUR SITE'
Package deployment using ZIP Deploy initiated.
##[error]Failed to deploy web package to App Service.
##[error]Error: Error: Failed to deploy web package to App Service. Conflict (CODE: 409)
##[warning]Error: Failed to update deployment history. Error: Bad Request (CODE: 400)
App Service Application URL: OUR SITE

Here is our deployment YAML, sorry been at this for days now :(

# Node.js Express Web App to Linux on Azure
# Build a Node.js Express app and deploy it to Azure as a Linux web app.
# Add steps that analyze code, save build artifacts, deploy, and more:
# https://learn.microsoft.com/azure/devops/pipelines/languages/javascript

trigger:
- master

variables:

  # Azure Resource Manager connection created during pipeline creation
  azureSubscription: '[OUR SUB ID]'

  # Web app name
  webAppName: 'website-to-deploy'

  # Environment name
  environmentName: 'web-to-deploy'

  # Agent VM image name
  vmImageName: 'ubuntu-latest'

stages:
- stage: Build
  displayName: Build stage
  jobs:  
  - job: Build
    displayName: Build
    pool:
      vmImage: $(vmImageName)

    steps:
    - task: NodeTool@0
      inputs:
        versionSpec: '10.x'
      displayName: 'Install Node.js'

    - script: |
        npm install
        npm run build --if-present
        npm run test --if-present
      displayName: 'npm install, build and test'

    - task: ArchiveFiles@2
      displayName: 'Archive files'
      inputs:
        rootFolderOrFile: '$(System.DefaultWorkingDirectory)'
        includeRootFolder: false
        archiveType: zip
        archiveFile: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
        replaceExistingArchive: true

    - upload: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
      artifact: drop
    - task: AzureRmWebAppDeployment@4
      inputs:
        ConnectionType: 'AzureRM'
        azureSubscription: 'OUR SUBSCRIPTION'
        appType: 'webAppLinux'
        WebAppName: 'site-to-deploy'
        packageForLinux: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
        RuntimeStack: 'NODE|12-lts'
        StartupCommand: 'npm start'
        AppSettings: 'WE DO HAVE SOME SETTINGS'     

Please note: I have tried adding WEBSITE_WEBDEPLOY_USE_SCM = true to the configuration, this has not helped.
There have been no changes to the above build YAML that was successfully working and feeding into a release pipeline

Thanks for any help.

UPDATE : Ticket raised with MS Dev-Ops You can add system.debug: true in your variables section to get far more verbose logging.
This has allowed me to see that the AppService returns the 409 code as it believes there is a deployment already underway. If and when I get a resolution I will edit this post.

Here is the debug info:

##[debug]Encountered a retriable status code: 409. Message: 'Conflict'.
##[debug][POST]https://$web040-glndev-com:***@web040-glndev-com.scm.azurewebsites.net/api/zipdeploy?isAsync=true&deployer=VSTS_ZIP_DEPLOY
##[debug]Could not parse response: {}
##[debug]Response: undefined
##[debug]Encountered a retriable status code: 409. Message: 'Conflict'.
##[debug][POST]https://$web040-glndev-com:***@web040-glndev-com.scm.azurewebsites.net/api/zipdeploy?isAsync=true&deployer=VSTS_ZIP_DEPLOY
##[debug]Could not parse response: {}
##[debug]Response: undefined
##[debug]ZIP Deploy response: {"statusCode":409,"statusMessage":"Conflict","headers":{"transfer-encoding":"chunked","content-type":"text/plain; charset=utf-8","server":"Kestrel","date":"Wed, 15 Jan 2020 17:40:47 GMT","connection":"close"},"body":"There is a deployment currently in progress. Please try again when it completes."}
##[error]Failed to deploy web package to App Service.
##[debug]Processed: ##vso[task.issue type=error;]Failed to deploy web package to App Service.
##[debug]task result: Failed
##[error]Error: Error: Failed to deploy web package to App Service. Conflict (CODE: 409)
##[debug]Processed: ##vso[task.issue type=error;]Error: Error: Failed to deploy web package to App Service. Conflict (CODE: 409)
##[debug]Processed: ##vso[task.complete result=Failed;]Error: Error: Failed to deploy web package to App Service. Conflict (CODE: 409)
##[debug][POST]https://management.azure.com/subscriptions/7a7aad03-79b0-4118-8dd1-8ebd63716c6a/resourceGroups/appsvc_linux_centralus/providers/Microsoft.Web/sites/web040-glndev-com/config/appsettings/list?api-version=2016-08-01
##[debug]Correlation ID from ARM api call response : e4ebaf0f-7ccf-4b7b-ba4d-b70b8fd13bea
##[debug]Application Insights is not configured for the App Service. Skipping adding release annotation.

Ticket is here: 409 Unable to deploy web package

Upvotes: 22

Views: 36118

Answers (11)

Roman Starkov
Roman Starkov

Reputation: 61512

Nothing helped in my case short of deleting the deployment slot and creating a new one. Fortunately that is pretty easy to do.

Upvotes: 0

Alamakanambra
Alamakanambra

Reputation: 7891

I had this error 409 with .net, but I don't think dev-stack matters. Somehow the deployment process was stuck.

Check the deployment center for stuck pending zip deploy. You might see pending line before failed one: enter image description here

This also corelates to errors like:

There is a deployment currently in progress. Please try again when it completes

How to fix that?

  • The only thing that helped at the end was to Change the stack settings to something else, save it, and then change back to your desired one:

enter image description here

Weird, but working!

Upvotes: 0

Shafiqul Bari Sadman
Shafiqul Bari Sadman

Reputation: 246

Check if there is a variable 'WEBSITE_WEBDEPLOY_USE_SCM' set in Application settings of Azure App Service.

If it does not exist add it. Make sure that it is set to true.

enter image description here

After that restart the App Service and redeploy your application

Upvotes: 2

akisoft
akisoft

Reputation: 563

In my case i was having this error because i had previously connected a repo to my app service in the deployment center of the app service, by disconnecting the repo, my release pipeline works just fine.

Upvotes: 1

Wesley Masunika
Wesley Masunika

Reputation: 173

Switching from the free tier to a paid production plan solved my issue.

Upvotes: 0

Christian van R
Christian van R

Reputation: 707

I also had this problem, due to corrupted log files (and after that kudu/deployment process crashed). If you have a linux instance you could turn the option AppService log to off (reboot) and later turn it on again

Upvotes: 0

Paul Salmon
Paul Salmon

Reputation: 76

A mistake I made was to copy all the configurations from another function app over, including the WEBSITE_ENABLE_SYNC_UPDATE_SITE and the WEBSITE_RUN_FROM_PACKAGE. Removed them and redeployed.

Upvotes: 2

Kokul Jose
Kokul Jose

Reputation: 1742

I had the same error and the issue was with the size of webapp. I tried to deploy a webapp with more than 1 GB to a Azure webapp with App service Plan Tier of 1GB.

Upvotes: 4

ChrisWue
ChrisWue

Reputation: 19050

Right now (July/August 2020) the issue was actually a Microsoft update to the VMs backing the app services in certain regions as outlined in this github issue: https://github.com/projectkudu/kudu/issues/3042

The workarounds (listed in this response: https://github.com/projectkudu/kudu/issues/3042#issuecomment-665997217) seem to help. Either

  1. Restart Kudu via the SCM portal (kill w3wp process via the Process Explorer tab)
  2. Restart the app service (incurs downtime)
  3. Scale your service up and down (although some people reported they had to do a deployment in between)

Upvotes: 6

Sachin
Sachin

Reputation: 367

Restarting the App Service solved my problem.

My App Service Plan was already a paid subscription and there was no issue with the capacity. I just restarted the App Service and everything worked fine.

Upvotes: 24

Bibberty
Bibberty

Reputation: 4768

So after a lot of discussion with MS support, Here is the ticket

It transpires that the real issue is that my App Service Plan was at capacity. In development we were using the free service and there are limits. We had hit this limit and the message was really a red herring and not the real problem at all.

Anyway, I upgraded to the first tier of paid subscription and everything is now working.

Upvotes: 9

Related Questions