Deployment pipeline - Task AzureWebApp is long

Clement Fayol 20 Reputation points
2023-09-28T08:46:41.3+00:00

Hello

I am using the azure pipeline to deploy an artifact on my web service. Everything works fine but the task AzureWebApp take between 30 and 40 minutes to execute, which is very long for a deployment.

I build the app and then deploy it with the following pipeline :

stage: Deploy
    displayName: Deploy stage
    dependsOn: Build
    condition: succeeded()
    jobs:
    - deployment: Deploy
      environment: $(environmentName)
      displayName: Deploy
      pool:
        vmImage: $(vmImageName)
      strategy:
        runOnce:
          deploy:
            steps:
            - task: AzureWebApp@1
              displayName: 'Azure Web App Deploy'
              inputs:
                azureSubscription: $(azureSubscription)
                appType: webAppLinux
                appName: $(webAppName)
                package: $(Pipeline.Workspace)/drop/$(Build.BuildId).zip
                runtimeStack: 'NODE|18-lts'
                startUpCommand: 'npm run start'

and here is my deployment logs :

Got service connection details for Azure App Service:'xx-xxx-xxx' 
Package deployment using ZIP Deploy initiated. 
Deploy logs can be viewed at https://.............../ 
Successfully deployed web package to App Service. 
Successfully updated deployment History at https://.............../
App Service Application URL: http://........../ 
Finishing: Azure Web App Deploy

The line is block for 25 minutes at

Package deployment using ZIP Deploy initiated.

Do you have any idea of how can I improve it or have more detail on the deployment step ?

Or is it normal ? If it's normal, should I use a custom task?

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,057 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. brtrach-MSFT 16,686 Reputation points Microsoft Employee
    2023-10-02T02:05:19.89+00:00

    @Clement Fayol The deployment time can vary depending on the size of your application and the resources allocated to your deployment. However, 30-40 minutes seems like a long time for a deployment.

    The line "Package deployment using ZIP Deploy initiated" indicates that the deployment package is being uploaded to Azure. This step can take some time depending on the size of your package and the network speed. You can try to optimize the package size by removing unnecessary files or compressing the files to reduce the upload time.

    You can also try using the Kudu REST API to deploy your application instead of the AzureWebApp task. The Kudu REST API provides more control over the deployment process and can be faster than the AzureWebApp task. Here is an example of how to use the Kudu REST API to deploy your application:

    - task: PowerShell@2
      inputs:
        targetType: 'inline'
        script: |
          $username = '$(username)'
          $password = '$(password)'
          $webAppName = '$(webAppName)'
          $packagePath = '$(Pipeline.Workspace)/drop/$(Build.BuildId).zip'
          $apiUrl = "https://$webAppName.scm.azurewebsites.net/api/zipdeploy"
          $base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $username, $password)))
          Invoke-RestMethod -Uri $apiUrl -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)} -Method POST -InFile $packagePath -ContentType "multipart/form-data"
    
    
    

    This script uploads the deployment package to the Kudu REST API endpoint and deploys the application. You will need to replace the variables with your own values.


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.