0
votes

I started using the strategy runonce yaml schema so i can add environment tag to my relase and add approval steps. https://docs.microsoft.com/en-us/azure/devops/pipelines/yaml-schema?view=azure-devops&tabs=schema

BUT doing so AzureRmWebAppDeployment@4 step deploy whol file in the format below

/site/wwwroot/mywebApi/Content/D_C/a/1/s/src/mywebApi/obj/Release/Package/PackageTmp/

instead of unziping the package to /site/wwwroot/mywebApi/

this used to work when i did not use strategy

this used to work


jobs:
  - job: Deploy
    variables:
      vmImage: 'windows-latest'   
    pool:
      vmImage: $(vmImage)  
    displayName: 'Deploy ${{ parameters.project }} ${{ parameters.envName }}'         
    continueOnError: "false"
    steps:
    - task: DownloadBuildArtifacts@0
      inputs:
        buildType: 'current'
        downloadType: 'single'
        artifactName: '${{ parameters.project }}${{ parameters.envName }}'
        downloadPath: '$(build.artifactStagingDirectory)'
    - task: AzureRmWebAppDeployment@4
      inputs:
        ConnectionType: 'AzureRM'
        azureSubscription: '****Azure'
        appType: 'webApp'
        WebAppName: '${{ parameters.webAppName }}'
        deployToSlotOrASE: true
        ResourceGroupName: '****'
        SlotName: '${{ parameters.slotName }}'
        VirtualApplication: '${{ parameters.virtualApplication }}'
        packageForLinux: '$(build.artifactStagingDirectory)/**/*.zip'

this does not work but this is what i want for tagging release with environment

jobs:
  # track deployments on the environment
- deployment: DeployWeb
  displayName: deploy paystub Web App 
  environment: ${{ parameters.envName }}  
  variables:
    vmImage: 'windows-latest'   
  pool:
    vmImage: $(vmImage)  
  continueOnError: "false"
  strategy:
    runOnce:
      deploy:
        steps:
        - task: DownloadBuildArtifacts@0
          inputs:
            buildType: 'current'
            downloadType: 'single'
            artifactName: '${{ parameters.project }}${{ parameters.envName }}'
            downloadPath: '$(build.artifactStagingDirectory)'
        - task: AzureRmWebAppDeployment@4
          inputs:
            ConnectionType: 'AzureRM'
            azureSubscription: '***Azure'
            appType: 'webApp'
            WebAppName: '${{ parameters.webAppName }}'
            deployToSlotOrASE: true
            ResourceGroupName: '*****'
            SlotName: '${{ parameters.slotName }}'
            VirtualApplication: '${{ parameters.virtualApplication }}'
            packageForLinux: '$(build.artifactStagingDirectory)/**/*.zip'

I would expect the new step to also deploy the code in this folder package to /site/wwwroot/mywebApi/

instead of doing some kudu copy to

/site/wwwroot/mywebApi/Content/D_C/a/1/s/src/mywebApi/obj/Release/Package/PackageTmp/

1

1 Answers

0
votes

I was able to reproduce the same scenario. Unfortunately I didnot find a way to fix it by configure task AzureRmWebAppDeployment. The task seems automatically use kudu to copy the files to Azure App service, while msdeploy is used to deploy the files in non-strategy pipeline. You can report this issue here.

I found a work around by changing the msbuild arguments of vsbuild task, and adding a zip archive task. Check below:

Use /t: publish to publish the builds to $(build.artifactstagingdirectory)\publish folder to be zipped in ArchiveFiles task.

- task: VSBuild@1
      displayName: 'Build solution **\*.sln'
      inputs:
        msbuildArgs: '/t:publish /p:outputpath="$(build.artifactstagingdirectory)\\"'
        platform: '$(BuildPlatform)'
        configuration: '$(BuildConfiguration)'
        clean: true
        restoreNugetPackages: true

Use archiveFiles task to zip all the files in \publish folder from above step.

 - task: ArchiveFiles@2
      inputs:
        rootFolderOrFile: '$(Build.ArtifactStagingDirectory)\\publish\\*'
        includeRootFolder: true
        archiveType: 'zip'
        archiveFile: '$(Build.ArtifactStagingDirectory)/package/$(Build.BuildId).zip'
        replaceExistingArchive: true

Use PublishBuildArtifacts task to publish the zip file created by above step

 - task: PublishBuildArtifacts@1
      displayName: 'Publish Artifact: drop'
      inputs:
        pathtoPublish: '$(Build.ArtifactStagingDirectory)\\package\\' 
        artifactName: 'strategy' 

By above steps the zip file that downloaded in Deploy stage will only include the deployed code.

Hope above step be helpful to you.