简体   繁体   English

使用VSTS部署Azure WebJob

[英]Deploy Azure WebJob using VSTS

I'm having some issues deploying an Azure WebJob using Visual Studio Team Services (VSTS). 我在使用Visual Studio Team Services(VSTS)部署Azure WebJob时遇到了一些问题。

The WebJob seems to be deployed successfully but it breaks the Azure website that is hosted in the same App Service! WebJob似乎已成功部署,但它破坏了托管在同一App Service中的Azure网站! I don't have this problem if I deploy using VS2013. 如果我使用VS2013部署,我没有这个问题。

This is my build task that generates the WebJob deployment package: 这是我的构建任务,它生成WebJob部署包:

构建任务 - 生成Azure WebJob部署包

And this is my deployment task: 这是我的部署任务:

部署WebJob任务

There are no errors when I deploy the Azure WebJob. 部署Azure WebJob时没有错误。 If I go to the Azure Portal I see the WebJob is there, and it runs successfully. 如果我去Azure门户,我看到WebJob就在那里,它运行成功。 WebJob files are copied into the wwwroot\\App_Data\\jobs\\triggered\\RemoveExpiredDids folder as expected, but the problem is that some other files will be copied into the wwwroot\\App_Data\\bin folder, which will break the existing website that was already deployed into that App Service!!! WebJob文件按预期复制到wwwroot\\App_Data\\jobs\\triggered\\RemoveExpiredDids文件夹中,但问题是其他一些文件将被复制到wwwroot\\App_Data\\bin文件夹中,这会破坏已部署到的现有网站那个App服务!!!

So I decided to find out why this was happening. 所以我决定找出为什么会发生这种情况。 After downloading and extracting the deployment package I saw there are 2 folders ( app_data and bin ) and the scheduler file ( settings.job ): 下载并解压缩部署包后,我看到有2个文件夹( app_databin )和调度程序文件( settings.job ):

WebJob部署包

This explains why some assemblies are coppied into the wwwroot\\App_Data\\bin of the App Service. 这解释了为什么某些程序集被copped到App Service的wwwroot\\App_Data\\bin中。 The strange thing is that this doesn't happen when deploying from VS2013!!! 奇怪的是,从VS2013部署时不会发生这种情况! I took a look into the MSBuild log and found the following line: 我查看了MSBuild日志,找到了以下行:

Object dirPath ([app service name]\\bin) skipped due to skip directive 'SkipBinFolderOnDeploy'. 由于跳过指令“SkipBinFolderOnDeploy”,跳过了对象dirPath([app service name] \\ bin)。

Concluding, bin folder is included when deploying the Azure WebJob from VSTS but is excluded when deploying it from VS2013. 总结一下,从VSTS部署Azure WebJob时会包含bin文件夹,但从VS2013部署它时会被排除。

So my question is: how to prevent the bin folder from being deployed when using VSTS? 所以我的问题是: 如何在使用VSTS时阻止部署bin文件夹? Is there any MSBuild parameter/flag to do this? 是否有任何MSBuild参数/标志来执行此操作?

I've had issue with this particular problem as well. 我也遇到过这个问题。

The latest method I found is using Web Deploy Operation Settings , -skip:Directory= (in this case it would be -skip:Directory='\\\\bin') when you create your azure deploy task in the release definition (Additional arguments). 我发现的最新方法是在发布定义(附加参数)中创建azure deploy任务时使用Web部署操作设置 ,-skip:Directory =(在这种情况下,它将是-skip:Directory ='\\\\ bin') 。 I've seen that this indeed excludes the bin folder from the update actions ( result ). 我已经看到这确实排除了更新操作( 结果 )中的bin文件夹。

Let me know if this helps you in any way. 如果这对您有任何帮助,请告诉我。

Refer to these ways to deploy webjob to azure: 请参阅以下方法将webjob部署到azure:

  1. Modify Visual Studio Build task to deploy webjob with FileSystem (MSBuild Arguments: /p:DeployOnBuild=true /p:WebPublishMethod=FileSystem /p:publishUrl="$(build.artifactstagingdirectory)\\\\WebJob" /p:DeployDefaultTarget=WebPublish ) 修改Visual Studio Build任务以使用FileSystem部署webjob(MSBuild参数: /p:DeployOnBuild=true /p:WebPublishMethod=FileSystem /p:publishUrl="$(build.artifactstagingdirectory)\\\\WebJob" /p:DeployDefaultTarget=WebPublish
  2. Add Delete Files task to release definition to delete bin folder (Source Folder: $(System.DefaultWorkingDirectory)/WebJobVnext/drop/WebJob ); 添加删除文件任务以释放定义以删除bin文件夹(源文件夹: $(System.DefaultWorkingDirectory)/WebJobVnext/drop/WebJob ); Contents: bin ) 内容: bin
  3. Modify Azure App Service Deploy task (1. Uncheck Publish using Web Deploy option. 2. Package or folder: $(System.DefaultWorkingDirectory)/[artifact name] /drop/WebJob ) 修改Azure App Service Deploy任务(1.取消选中使用Web Deploy发布选项.2。包或文件夹: $(System.DefaultWorkingDirectory)/[artifact name] /drop/WebJob

I was finally able to fix it, thanks @starain-MSFT for pointing me in the right direction. 我终于能够解决它,感谢@ starain-MSFT指出我正确的方向。 I had to make some minor changes, though. 不过,我不得不做一些小改动。 This is the task that creates the deployment package: 这是创建部署包的任务:

生成Azure WebJob部署包

MSBuild arguments: MSBuild参数:

/p:DeployOnBuild=true /p:WebPublishMethod=FileSystem /p:DeployDefaultTarget=WebPublish /p:Configuration=$(BuildConfiguration) /p:OutputPath=.\\bin\\ /p:publishUrl="$(build.artifactstagingdirectory)\\temp\\WebJob" / p:DeployOnBuild = true / p:WebPublishMethod = FileSystem / p:DeployDefaultTarget = WebPublish / p:Configuration = $(BuildConfiguration)/ p:OutputPath =。\\ bin \\ /p:publishUrl="$(build.artifactstagingdirectory)\\temp \\ WebJob”

The difference here comparing to @starain-MSFT answer is that I had to add the /p:OutputPath= parameter, otherwise I'd get the following error: 这里与@ starain-MSFT答案的区别在于我必须添加/p:OutputPath=参数,否则我会收到以下错误:

The OutputPath property is not set for project 未为项目设置OutputPath属性

After generating the package, I delete the bin folder and zip it (this reduces the build time). 生成包后,我删除bin文件夹并压缩它(这减少了构建时间)。

This is my deployment task: 这是我的部署任务:

使用VSTS部署Azure WebJob

Please note that $(DeploymentPackagePath) is the path to the zip file that contains the deployment package, as mentioned before. 请注意, $(DeploymentPackagePath)是包含部署包的zip文件的路径,如前所述。 It doesn't matter if you deploy the package as a zip file or if you unzip it and deploy the folder, it works both ways. 将软件包部署为zip文件或者解压缩并部署文件夹无关紧要,它可以兼顾两种方式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在 Visual Studio 中针对不同环境使用不同配置部署 Azure WebJob - How to deploy Azure WebJob using different configurations for different environments in Visual Studio VSTS和Azure部署连续交付时出错 - Error with VSTS and Azure Deploy Continuous Delivery 如何使用VSTS在Docker上配置ASPNET Core以使用单元测试和环境变量构建,运行测试并部署到Azure - How to configure ASPNET Core with Docker using VSTS to build, run tests and deploy to Azure with Unit Tests and Environment Variables 使用Azure中的Web应用程序使用多个部署使Webjob成为单例 - Making a Webjob a singleton using multiple deployments using Web Apps in Azure 使用VSTS版本发布Azure Data Factory项目 - Release Azure Data Factory project using VSTS Release Azure WebJob在VS 2015中不起作用 - Azure WebJob not working in VS 2015 Azure WebJob - 创建目录失败 - Azure WebJob - Create Directory fails VSTS:发布并部署控制台应用程序 - VSTS: Release and deploy a console application Azure:HOWTO/最佳实践:使用 Blob Q 将带有 Webjob 的 WebApp 发布到多个目的地? - Azure : HOWTO/BEST-Practice : Publish WebApp with Webjob using blobs Q's to multiple destinations? 指定分配给计划的Azure WebJob的作业集合 - Specifying the Job Collection that a scheduled Azure WebJob is assigned to
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM