I've been trying to deploy my FastAPI application on Azure DevOps for the past two days. It was working perfectly before, but now it's not working even though I haven't made any changes to the pipeline.

Nisarg Jadhav 0 Reputation points
2025-01-23T07:01:06.56+00:00

My Pipeline is :

trigger:
- main

variables:
  azureServiceConnectionId: service_connectionID
  webAppName: appname
  vmImageName: 'image'
  environmentName: 'env'
  projectRoot: $(System.DefaultWorkingDirectory)
  pythonVersion: '3.11'

stages:
- stage: Build
  displayName: Build stage
  jobs:
  - job: BuildJob
    pool:
      vmImage: $(vmImageName)
    steps:
    # Set up Python environment
    - task: UsePythonVersion@0
      inputs:
        versionSpec: '$(pythonVersion)'
      displayName: 'Use Python $(pythonVersion)'

    # Install dependencies
    - script: |
        python -m venv antenv
        source antenv/bin/activate
        python -m pip install --upgrade pip
        pip install setuptools wheel
        pip install -r requirements.txt
      workingDirectory: $(projectRoot)
      displayName: 'Install requirements'
      
    # Create deployment package
    - task: ArchiveFiles@2
      displayName: 'Archive files'
      inputs:
        rootFolderOrFile: '$(projectRoot)'
        includeRootFolder: false
        archiveType: zip
        archiveFile: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
        replaceExistingArchive: true

    # Publish build artifacts
    - task: PublishBuildArtifacts@1
      inputs:
        PathtoPublish: '$(Build.ArtifactStagingDirectory)'
        ArtifactName: 'drop'
        publishLocation: 'Container'

- stage: Deploy
  displayName: 'Deploy Web App'
  dependsOn: Build
  condition: succeeded()
  jobs:
  - deployment: DeploymentJob
    environment: $(environmentName)
    pool:
      vmImage: $(vmImageName)
    strategy:
      runOnce:
        deploy:
          steps:
          # Deploy the web app
          - task: AzureWebApp@1
            displayName: 'Deploy Azure Web App'
            inputs:
              azureSubscription: $(azureServiceConnectionId)
              appType: 'webAppLinux'
              appName: $(webAppName)
              package: '$(Pipeline.Workspace)/drop/$(Build.BuildId).zip'
              runtimeStack: 'PYTHON|3.11'
              startUpCommand: 'startup.txt'
              deploymentMethod: 'auto'

My startup command is :

gunicorn -w 4 -k uvicorn.workers.UvicornWorker --timeout 600 -b 0.0.0.0:8000 app:app

and its giving me error as

##[error]Failed to deploy web package to App Service.

##[warning]Can't find loc string for key: KuduStackTraceURL

##[error]KuduStackTraceURL https://:@ai-commission-dsbfcbduhcb6gtfz.scm.eastus2-01.azurewebsites.net/api/vfs/LogFiles/kudu/trace

##[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)

Azure Static Web Apps
Azure Static Web Apps
An Azure service that provides streamlined full-stack web app development.
1,056 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Nisarg Jadhav 0 Reputation points
    2025-01-24T07:34:48.6233333+00:00

    My error is solved:

    First, I went to the Debug Console. Then, in the command prompt, I navigated to my file at home/site/wwwroot and deleted all files from there. After that, I tried deploying again, and my error was resolved.

    To access the Debug Console, go to your link and navigate to /DebugConsole. There, you will see a command prompt.


  2. Shree Hima Bindu Maganti 2,415 Reputation points Microsoft Vendor
    2025-01-24T11:55:12.7133333+00:00

    Hi @Nisarg Jadhav
    I'm glad that you were able to resolve your issue and thank you for posting your solution so that others experiencing the same thing can easily reference this! Since the Microsoft Q&A community has a policy that "The question author cannot accept their own answer. They can only accept answers by others ", I'll repost your solution in case you'd like to accept the answer.

    First, I went to the Debug Console. Then, in the command prompt, I navigated to my file at home/site/wwwroot and deleted all files from there. After that, I tried deploying again, and my error was resolved.

    To access the Debug Console, go to your link and navigate to /DebugConsole. There, you will see a command prompt.
    If this answers your query, do click Accept Answer and Yes for was this answer helpful. And, if you have any further query do let us know.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.