I thought this would be a pretty straightforward task and there is quite a bit of documentation out there but I've had zero luck with any of it and am assuming that it is pretty much all out of date.
我认为这是一个很简单的任务,有很多的文档,但是我没有任何的运气,而且我认为它几乎已经过时了。
I have .NET Core MVC 6 Web App that I've been developing for a while and need to set up a WebJob for it on Azure. I want to deploy this alongside the app using the continuous deployment system Azure provides that the app is already using. According to Kudu docs it's possible:
我已经开发了一段时间的。net Core MVC 6 Web应用程序,需要在Azure上为它设置一个WebJob。我想在应用程序中部署这个应用程序,使用持续部署系统Azure,这是应用程序已经在使用的。根据库杜文献,这是可能的:
https://github.com/projectkudu/kudu/wiki/Web-Jobs deploying-net-console-webjobs-alongside-an-aspnet-application
Which states:
州:
This works both when deploying directly from Visual Studio (WebDeploy), or via git.
当直接从Visual Studio (WebDeploy)或通过git进行部署时,这两者都可以工作。
It references this link (https://azure.microsoft.com/en-us/documentation/articles/websites-dotnet-deploy-webjobs/), which I've been attempting to follow with no success.
它引用了这个链接(https://azure.microsoft.com/en-us/documentation/articles/websites-dotnet-deploy-webjobs/),我一直在尝试这样做,但没有成功。
I have the latest version of Visual Studio 2015, .NET Core 1.0.0 & Tools and the Azure SDK.
我有最新版本的Visual Studio 2015,。net Core 1.0.0 & Tools和Azure SDK。
First thing that becomes apparent is that I do not have the scaffolding options as shown in the screenshots on the Azure docs and after failing to find any missing dependencies I resorted to trying to set it up manually as described.
首先,显而易见的是,我没有Azure文档屏幕截图所示的搭建选项,在没有找到任何丢失的依赖项之后,我尝试按照描述手动设置它。
Even after putting the required files in the locations specified (webjobs-list.json
and webjob-publish-settings.json
) and configuring them for my project, and adding Microsoft.Web.WebJobs.Publish
to the WebJob project, Kudu does not find the WebJob via the continuous deployment system.
甚至在将所需的文件放入指定的位置之后(webjob -list)。json和webjob-publish-settings.json)并为我的项目配置它们,并添加microsoft.webjobs。发布到WebJob项目,Kudu没有通过持续部署系统找到WebJob。
I've tried several approaches and variations based on the documentation I've found out there but I just can't get it working and all other SO questions are year(s) old.
根据我发现的文档,我尝试了几种方法和变体,但是我不能让它正常工作,所有其他的问题都是年份的问题。
Does anyone know what I'm doing wrong? Is this even still possible with the latest version of .NET Core MVC?
有人知道我做错了什么吗?对于最新版本的。net Core MVC,这是否仍然可行?
1 个解决方案
#1
4
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.
WebJobs的文件存储在“App_Data/jobs/continuous”或“App_Data/jobs/ jobs/trigger”文件夹下,因此我可以使用一种方法来部署Web应用程序和WebJob,即在构建期间手工复制这些文件夹所需的所有WebJobs文件。我认为这将适合VS工具正在更新。
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.
我的解决方案与您的稍有不同,因为我正在使用Visual Studio Team Services来构建和发布我的应用程序到Azure,但是概念是一样的。您可以在Visual Studio中使用post构建事件来运行将这些文件复制到jobs文件夹中的脚本。
Below are the steps I've configured in VSTS build definition:
下面是我在VSTS构建定义中配置的步骤:
-
Command Line task: Tool: dotnet Arguments: restore
命令行任务:工具:dotnet参数:恢复
-
Visual Studio Build task: Solution: **\MyApp.sln Platform: $(BuildPlatform) Configuration: $(BuildConfiguration) Visual Studio Version: Visual Studio 2015
Visual Studio构建任务:解决方案:**\MyApp。sln平台:$(构建平台)配置:$(构建配置)Visual Studio版本:Visual Studio 2015
-
Command Line task: Tool: dotnet Arguments: publish -c $(BuildConfiguration)
命令行任务:工具:dotnet参数:发布-c $(构建配置)
-
Command Line task: Tool: dotnet Arguments: publish -c $(BuildConfiguration) $(Build.SourcesDirectory)\src\MyApp.Jobs\project.json
命令行任务:工具:dotnet参数:发布-c $(BuildConfiguration) $(Build.SourcesDirectory)\src\MyApp.Jobs\project.json。
-
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/
复制文件任务(这是一个技巧):源文件夹:src/MyApp.Jobs/bin/$(BuildConfiguration)/netcoreapp1.0/发布/内容:**目标文件夹:src/MyApp.Web/bin/$(BuildConfiguration)/netcoreapp1.0/publish/App_Data/jobs/触发/MyJobName/。
-
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
归档文件任务:将根文件夹(或文件)归档:src/MyApp.Web/bin/$(build - configuration)/netcoreapp1.0/publish/ Prefix根文件夹名称归档路径:检查归档类型:zip归档文件创建:网站。zip替换现有存档:检查。
-
Copy Files task: Source folder: Contents: **/*.zip Target folder: $(Build.ArtifactStagingDirectory)
复制文件任务:源文件夹:内容:**/*。zip目标文件夹:$(Build.ArtifactStagingDirectory)
-
Publish Build Artifacts task: Path do publish: $(Build.ArtifactStagingDirectory) Artifact Name: drop Artifact type: Server
发布构建构件任务:路径do Publish: $(Build. artifactstagingdirectory)构件名称:drop构件类型:Server
#1
4
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.
WebJobs的文件存储在“App_Data/jobs/continuous”或“App_Data/jobs/ jobs/trigger”文件夹下,因此我可以使用一种方法来部署Web应用程序和WebJob,即在构建期间手工复制这些文件夹所需的所有WebJobs文件。我认为这将适合VS工具正在更新。
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.
我的解决方案与您的稍有不同,因为我正在使用Visual Studio Team Services来构建和发布我的应用程序到Azure,但是概念是一样的。您可以在Visual Studio中使用post构建事件来运行将这些文件复制到jobs文件夹中的脚本。
Below are the steps I've configured in VSTS build definition:
下面是我在VSTS构建定义中配置的步骤:
-
Command Line task: Tool: dotnet Arguments: restore
命令行任务:工具:dotnet参数:恢复
-
Visual Studio Build task: Solution: **\MyApp.sln Platform: $(BuildPlatform) Configuration: $(BuildConfiguration) Visual Studio Version: Visual Studio 2015
Visual Studio构建任务:解决方案:**\MyApp。sln平台:$(构建平台)配置:$(构建配置)Visual Studio版本:Visual Studio 2015
-
Command Line task: Tool: dotnet Arguments: publish -c $(BuildConfiguration)
命令行任务:工具:dotnet参数:发布-c $(构建配置)
-
Command Line task: Tool: dotnet Arguments: publish -c $(BuildConfiguration) $(Build.SourcesDirectory)\src\MyApp.Jobs\project.json
命令行任务:工具:dotnet参数:发布-c $(BuildConfiguration) $(Build.SourcesDirectory)\src\MyApp.Jobs\project.json。
-
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/
复制文件任务(这是一个技巧):源文件夹:src/MyApp.Jobs/bin/$(BuildConfiguration)/netcoreapp1.0/发布/内容:**目标文件夹:src/MyApp.Web/bin/$(BuildConfiguration)/netcoreapp1.0/publish/App_Data/jobs/触发/MyJobName/。
-
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
归档文件任务:将根文件夹(或文件)归档:src/MyApp.Web/bin/$(build - configuration)/netcoreapp1.0/publish/ Prefix根文件夹名称归档路径:检查归档类型:zip归档文件创建:网站。zip替换现有存档:检查。
-
Copy Files task: Source folder: Contents: **/*.zip Target folder: $(Build.ArtifactStagingDirectory)
复制文件任务:源文件夹:内容:**/*。zip目标文件夹:$(Build.ArtifactStagingDirectory)
-
Publish Build Artifacts task: Path do publish: $(Build.ArtifactStagingDirectory) Artifact Name: drop Artifact type: Server
发布构建构件任务:路径do Publish: $(Build. artifactstagingdirectory)构件名称:drop构件类型:Server