1
votes

I have a dot net core 2.0 console app which I need to publish in Azure as webjob through continuous build and deployment in VSTS. I have created a web app already in Azure and defined CI and CD tasks in VSTS for the console app's project.

The issue is that whenever these tasks run, webapp gets deployed successfully but the webjob does not get deployed. However, it gets deployed when I use the artifact (zip folder created after build process) and upload it manually to Azure webjob section.

I think deploying the artifact using powershell script might be a solution but I have tried zipdeploy API of Kudu as well but to no use. Can someone please help or point me to a reference for extracting the artifact generated from build process and deploy it using CD tasks so that the webjob gets published alongwith webapp.

1

1 Answers

1
votes

With general web application, if you link web job project to the web (right click web app in Visual Studio > Add > New Azure WebJob project/Existing project as WebJob), you can refer to these steps below:

  1. Create a new build definition
  2. Add NuGet Tool Installer task
  3. Add NuGet restore task (Path to solution, packages.config: ***.sln)
  4. Add Visual Studio Build task (MSBuild Arguments: /p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactstagingdirectory)\")
  5. Add Publish Artifact task (Path to publish: $(build.artifactstagingdirectory))
  6. Queue build
  7. Create a new release definition
  8. Add Deploy Azure App Service task (Package or folder: {web app zip file path}; Choose Publish using Web deploy)

Otherwise:

  1. Create a new build definition
  2. Add NuGet Tool Installer task
  3. Add NuGet restore task (Path to solution, packages.config: ***.sln)
  4. Add Visual Studio Build task (/p:DeployOnBuild=true /p:WebPublishMethod=FileSystem /p:publishUrl="$(build.artifactstagingdirectory)\" /p:DeployDefaultTarget=WebPublish
  5. Add necessary task to build web job project (e.g. Visual Studio build)
  6. Add Copy Files task to copy web job’ build result to appropriate folder in web app published folder ($(build.artifactstagingdirectory)) (App_Data/jobs/continuous for continuous webjobs or App_Data/jobs/triggered for scheduled and on-demand WebJobs)
  7. Add Archive Files task (Root folder or file to archive: $(build.artifactstagingdirectory); Archive file to create: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip)
  8. Add Publish Artifact task
  9. Create a new release definition
  10. Add Deploy Azure App Service task (Package or folder: {web app zip file path}; Choose Publish using Web deploy)