How do I deploy an Azure WebJob alongside a .NET Core Web App via Git?

人走茶凉 提交于 2019-11-28 20:37:58

WebJobs' files are stored under the 'App_Data/jobs/continuous' or 'App_Data/jobs/triggered' folders, so one way I could use to deploy both Web App and WebJob is manually copying all WebJobs' files needed to these folders during build time. I think this will fit while VS tooling is being updated.

My solution is a little different from yours since I'm using Visual Studio Team Services to build and release my app to Azure, but the concept is the same. You can use a post build event in Visual Studio to run a script that copies these files to the jobs' folder.

Below are the steps I've configured in VSTS build definition:

  1. Command Line task: Tool: dotnet Arguments: restore

  2. Visual Studio Build task: Solution: **\MyApp.sln Platform: $(BuildPlatform) Configuration: $(BuildConfiguration) Visual Studio Version: Visual Studio 2015

  3. Command Line task: Tool: dotnet Arguments: publish -c $(BuildConfiguration)

  4. Command Line task: Tool: dotnet Arguments: publish -c $(BuildConfiguration) $(Build.SourcesDirectory)\src\MyApp.Jobs\project.json

  5. Copy Files task (this is the trick): Source folder: src/MyApp.Jobs/bin/$(BuildConfiguration)/netcoreapp1.0/publish/ Contents: ** Target folder: src/MyApp.Web/bin/$(BuildConfiguration)/netcoreapp1.0/publish/App_Data/jobs/triggered/MyJobName/

  6. Archive Files task: Root folder (or file) to archive: src/MyApp.Web/bin/$(BuildConfiguration)/netcoreapp1.0/publish/ Prefix root folder name to archive path: unchecked Archive type: zip Archive file to create: website.zip Replace existing archive: checked

  7. Copy Files task: Source folder: Contents: **/*.zip Target folder: $(Build.ArtifactStagingDirectory)

  8. Publish Build Artifacts task: Path do publish: $(Build.ArtifactStagingDirectory) Artifact Name: drop Artifact type: Server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!