0

I usually deployed the ASP.NET WebAPI application to Azure App Services directly from Visual Studio. It is working and sometime convenient.

Now I want to setup the CI/CD process from Azure DevOps. I create a build pipeline as

trigger:
- master

pool:
  vmImage: 'windows-latest'

variables:
  solution: '**/*.sln'
  buildPlatform: 'Any CPU'
  buildConfiguration: 'Release'

steps:
- task: NuGetToolInstaller@1

- task: NuGetCommand@2
  inputs:
    restoreSolution: '$(solution)'

- task: VSBuild@1
  inputs:
    solution: '$(solution)'
    msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactStagingDirectory)"'
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'

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

- task: PublishBuildArtifacts@1
  inputs:
    PathtoPublish: '$(Build.ArtifactStagingDirectory)'
    ArtifactName: 'drop'
    publishLocation: 'Container'``

The build pipeline works fine. Then I create a release as

- task: AzureWebApp@1
  displayName: 'Azure Web App Deploy: mylookupservice'
  inputs:
    azureSubscription: 'mylookupservice-connection'
    appType: webApp
    appName: 'mylookupservice'
    package: '$(System.DefaultWorkingDirectory)/_mylookupservice-build/drop'
    deploymentMethod: runFromPackage

But the release only copied the files to the wwwroot directory, not running any deployment commands

Directory of D:\home\site\wwwroot

05/31/2021  07:33 PM               138 10270.zip
05/31/2021  07:33 PM            14,566 mylookupservice.deploy.cmd
05/31/2021  07:33 PM             4,070 mylookupservice.deploy-readme.txt
05/31/2021  07:33 PM               490 mylookupservice.SetParameters.xml
05/31/2021  07:33 PM               435 mylookupservice.SourceManifest.xml
05/31/2021  07:33 PM         9,570,882 mylookupservice.zip

What should I change? Or someone can point me to an example online.

user3616544
  • 1,023
  • 1
  • 9
  • 31

1 Answers1

0

You can fix this by making the release task as follows:

- task: AzureWebApp@1
  displayName: 'Azure Web App Deploy: mylookupservice'
  inputs: 
    azureSubscription: 'mylookupservice-connection'
    appType: webApp
    appName: 'mylookupservice'
    package: '$(System.DefaultWorkingDirectory)/_mylookupservice-build/drop/*.zip'
    deploymentMethod: runFromPackage

The problem here is that you've set the drop folder path instead of the zip file's path for the "package" parameter in AzureWebApp@1. When you do so the task copies the folder content instead of deploying a package contained within a zip archive. In your case, it'll work if you change the folder path to the zip file path (the task accepts wildcard)

  • There are two zip files in the path. So the agent complains about it and requires to be more specific. So I tried both specific zip files (10270.zip and mylookupservice.zip). The first one gives no error, but not really deployed anything. and I can see a file "FAILED TO INITIALIZE RUN FROM PACKAGE.txt" at wwwroot. The second one gives the error: Publish using zip deploy option is not supported for msBuild package type. – user3616544 Jun 01 '21 at 03:04